:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1d2129; --muted: #6b7280; --line: #e3e6ea;
  --primary: #c8102e; --primary-dark: #a00d25; --ok: #1a7f37; --warn: #b26a00; --err: #c62828;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--err); min-height: 1em; }
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { margin: 0 0 14px; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 15px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 400; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f3b5bf; border-color: var(--primary); }
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }
.row.wrap { flex-wrap: wrap; align-items: flex-end; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 9px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { background: #f0f1f3; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.center-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; color: var(--primary); font-size: 17px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: #fbe9ec; color: var(--primary); }
.userbox { display: flex; align-items: center; gap: 8px; }

.tab-page { padding: 20px; max-width: 1900px; margin: 0 auto; }
.create-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.tool-list { display: flex; flex-direction: column; gap: 8px; }
.tool { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 3px; }
.tool span { color: var(--muted); font-size: 12px; }
.tool.active { border-color: var(--primary); box-shadow: 0 0 0 2px #fbe9ec; }

.pickers { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }   /* 이름표가 두 줄이어도 상자는 한 줄로 */
.picker { width: 120px; }
.picker .plabel { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.picker .pbox { width: 120px; height: 120px; border: 2px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: #fafafa center/cover no-repeat; color: var(--muted); font-size: 12px; position: relative; text-align: center; }
.picker .pbox:hover { border-color: var(--primary); }
.picker .pbox.filled { border-style: solid; }
.picker .pclear { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }
.badge-video { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }

.tagbar { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.tagbar button { border: 1px solid var(--line); background: #fafafa; border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.tagbar button:hover { border-color: var(--primary); }
/* 모델 라이선스 안내 (MiniMax H3 등) */
.model-notice { margin: 8px 0 4px; padding: 10px 12px; border: 1px solid #f0c36d; border-left: 4px solid #e0a020; border-radius: 8px; background: #fff8e6; color: #5c4400; font-size: 13px; }
.model-notice ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.6; }
/* 멀티참조: 사진마다 역할 고르기 */
.mr-roles { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 2px; margin-bottom: 12px; background: #fcfcfd; }
.mr-roles .field-label { margin-bottom: 8px; }
.mr-role { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.mr-role b { font-size: 13px; min-width: 52px; }
.mr-role select { flex: 1 1 220px; min-width: 0; max-width: 320px; padding: 6px 8px; }
.mr-thumb { width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--line); background: #eee center/cover no-repeat; flex: none; }
.mr-at { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.mr-at input { width: 72px; padding: 6px 8px; }
.mr-role-hint { margin-top: 2px; line-height: 1.6; }
/* 얼굴·손 다듬기 */
.fix-off { color: var(--warn); font-weight: 500; }
.fix-report { margin-top: 4px; padding: 5px 8px; border-radius: 6px; background: #eef6f0; color: #1d4d2c; font-size: 12px; line-height: 1.45; }
.fix-report.muted { background: #f4f5f7; color: var(--muted); }
/* 스토리보드: 컷 AI 시간 구성 · 원고 정리 */
.sb-motion-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.sb-motion-body label { margin-bottom: 8px; }
.sb-motion-body textarea { width: 100%; font-size: 12.5px; line-height: 1.5; }
.sb-motion-body textarea[name=motion_en] { background: #f7f8fa; }
.sb-motion-warn { margin: 0 0 8px; }
.sb-raw textarea { width: 100%; background: #f7f8fa; }
#sb-form .sb-refined textarea, .sb-script textarea[name=script] { font-size: 13px; line-height: 1.55; }
/* 영상 프롬프트 풀어 쓰기 */
.pe-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: -4px 0 12px; }
.pe-bar .pe-go { border-color: var(--primary); color: var(--primary); }
.pe-box { border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 8px; padding: 12px 12px 4px; margin-bottom: 12px; background: #fcfcfd; }
.pe-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.pe-head .muted { font-weight: 400; }
.pe-step { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.pe-box textarea { font-size: 13px; line-height: 1.55; }
.pe-box textarea[name=prompt_en] { background: #f7f8fa; }
.pe-acts { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.pe-warn { margin: -4px 0 10px; padding: 8px 10px; border-radius: 8px; background: #fff8e6; color: #7a4d00; font-size: 12px; line-height: 1.5; }
details.help { margin-bottom: 12px; font-size: 13px; }
details.help summary { cursor: pointer; color: var(--muted); }
details.help ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; }
details.help textarea { width: 100%; margin-top: 6px; }

.jobs { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.job-list { display: flex; flex-direction: column; gap: 10px; }
.job { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.job-title { font-weight: 700; font-size: 13px; flex: 1; }
.job-x { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer; border-radius: 4px; }
.job-x:hover { color: #d33; background: rgba(220, 50, 50, .1); }
.job-prompt { color: var(--muted); font-size: 12px; margin: 4px 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.job-prompt.full { display: block; overflow: visible; -webkit-line-clamp: unset; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.job-more { display: block; background: none; border: 0; padding: 0; margin: -2px 0 4px; font: inherit; font-size: 11px; color: var(--muted); cursor: pointer; }
.job-more:hover { color: var(--text); }
.status { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 700; white-space: nowrap; }
.status.queued { background: #fff4e0; color: var(--warn); }
.status.running { background: #e6f0ff; color: #1a5fd0; }
.status.done { background: #e5f5ea; color: var(--ok); }
.status.error, .status.canceled { background: #fdecec; color: var(--err); }
.job-files { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.job-files img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 1px solid var(--line); }
.job .err { color: var(--err); font-size: 12px; word-break: break-all; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.small-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); max-height: 60vh; overflow: auto; padding: 2px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.item .thumb { aspect-ratio: 1 / 1; background: #eee center/cover no-repeat; cursor: pointer; position: relative; }
.item .meta { padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .acts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }
.item .acts .btn { padding: 4px 8px; font-size: 11px; }
.shared-on { color: var(--primary); font-weight: 700; }
/* 공유함에서 내가 공유한 파일 */
.item.mine { border: 2px solid var(--primary); box-shadow: 0 0 0 3px #fbe9ec; }
.item.mine .meta { background: #fff5f6; }
.badge-mine { position: absolute; left: 6px; top: 6px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pick-item { cursor: pointer; }
.pick-item:hover { outline: 2px solid var(--primary); }
.drop-hint { outline: 3px dashed var(--primary); outline-offset: -10px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; padding: 16px; width: min(900px, 100%); max-height: 90vh; overflow: auto; }
.small-box { width: 360px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.viewer-box { width: min(1100px, 100%); }
#viewer-body img, #viewer-body video { max-width: 100%; max-height: 72vh; display: block; margin: 0 auto; border-radius: 8px; background: #000; }
/* 투명 PNG 는 바둑판 위에 (불투명한 사진에는 영향 없음) */
#viewer-body img { background: repeating-conic-gradient(#d6dae0 0% 25%, #fff 0% 50%) 50% / 24px 24px; }

.admin-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.admin-side { display: grid; gap: 16px; min-width: 0; }
.llm-form input:not([type=checkbox]) { width: 100%; box-sizing: border-box; }
#llm-result { margin-top: 10px; word-break: break-word; }
#llm-result .sample { margin-top: 4px; padding: 6px 8px; background: #f6f6f6; border-radius: 6px; }
#sns-admin-result { margin-top: 10px; word-break: break-word; }
.settings-layout { max-width: 640px; }
.sns-form { display: grid; gap: 10px; max-width: 420px; }
.sns-form input:not([type=checkbox]) { width: 100%; box-sizing: border-box; }
.sns-state { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafafa; margin: 8px 0 12px; line-height: 1.6; }
.sns-sent { color: var(--ok); font-weight: 700; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
.table td .btn { padding: 3px 8px; font-size: 11px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d2129; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 30; max-width: 80vw; }

@media (max-width: 1100px) {
  .create-layout { grid-template-columns: 1fr; }
  .tool-list { flex-direction: row; flex-wrap: wrap; }
  .jobs { position: static; max-height: none; }
  .admin-layout { grid-template-columns: 1fr; }
}

/* 서버 대기열 */
.queue-badge { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 5px 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.queue-badge.busy { background: #fff4e0; border-color: #f3d19b; color: var(--warn); }
.queue-badge.idle { background: #e5f5ea; border-color: #b7dfc3; color: var(--ok); }
.queue-badge.mine { background: #e6f0ff; border-color: #b3cdf5; color: #1a5fd0; }
.queue-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 16px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.q-row { display: flex; gap: 8px; align-items: baseline; }
.q-row .q-pos { min-width: 44px; font-weight: 700; color: var(--muted); font-size: 12px; }
.q-row .q-who { font-weight: 600; }
.q-row .q-time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.q-row.mine { background: #e6f0ff; border-radius: 6px; padding: 4px 6px; margin: 0 -6px; }
.q-row.mine .q-who { color: #1a5fd0; }
.q-run .q-pos { color: #1a5fd0; }
.q-row { flex-wrap: wrap; }
.q-live { flex-basis: 100%; padding-left: 52px; color: #1a5fd0; font-size: 12px; }
.job-live { color: #1a5fd0; font-size: 12px; margin-top: 4px; }
.job-live:empty { display: none; }
.q-sum { border-top: 1px dashed var(--line); padding-top: 6px; color: var(--muted); font-size: 12px; }

/* 서버 상태 (CPU·RAM·GPU·VRAM·온도) — 작은 막대, 값은 오른쪽 위·이름은 왼쪽 아래 */
.sys-box { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.sys-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 4px; }
.sys-bar { position: relative; height: 34px; border-radius: 5px; background: #2b2f36; overflow: hidden; color: #fff; font-size: 11px; line-height: 1; }
.sys-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--c, #3b82f6); transition: width .6s ease; }
.sys-bar b { position: absolute; right: 5px; top: 5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sys-bar span { position: absolute; left: 5px; bottom: 5px; opacity: .85; }
.sys-bar b, .sys-bar span { text-shadow: 0 1px 2px rgba(0, 0, 0, .55); }
.sys-bar.hot b { color: #fff3c4; }
.sys-models { font-size: 12px; }
.sys-models summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; color: var(--muted); }
.sys-models summary::-webkit-details-marker { display: none; }
.sys-sum::before { content: "▸"; display: inline-block; width: 12px; }
.sys-models[open] .sys-sum::before { content: "▾"; }
.sys-free { margin-left: auto; flex: none; }
.sys-model-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.sys-model { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; }
.sys-model .m-main { flex: 1; min-width: 0; }
.sys-model .m-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-model .m-file { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sys-model .m-mb { color: var(--muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sys-model .m-kind { color: var(--muted); font-size: 11px; font-weight: 400; }

details.tr { font-size: 12px; margin: 4px 0; }
details.tr summary { cursor: pointer; color: #1a5fd0; }
details.tr div { white-space: pre-wrap; background: #f6f8fb; border-radius: 6px; padding: 6px 8px; margin-top: 4px; color: var(--text); }

/* 가이드 영상 · 장면 캡처 */
.badge-tag { position: absolute; right: 4px; top: 4px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.presetbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.presetbar button { border: 1px solid var(--line); background: #fff5f6; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.presetbar button:hover { border-color: var(--primary); }
.viewer-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.viewer-acts:empty { display: none; }
.viewer-acts .viewer-del { margin-left: auto; color: var(--primary); border-color: var(--primary); }
.viewer-acts .viewer-del:hover { background: #fbe9ec; }

/* 같은 설정으로 N개 · 다시 만들기 · 다중 각도 */
.repeat-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.repeat-row label { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.repeat-row select { width: auto; padding: 5px 8px; }
.job-btns { display: flex; gap: 6px; margin-top: 6px; }
.field-label { font-weight: 600; margin: 4px 0 6px; }
.angle-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: 420px; margin-bottom: 12px; }
.angle-grid label { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 500; font-size: 13px; }
.angle-grid label:has(input:checked) { border-color: var(--primary); background: #fff5f6; }
.angle-center { display: flex; align-items: center; justify-content: center; border-radius: 8px; background: #f0f1f3; color: var(--muted); font-size: 12px; }

/* 나오지 말아야 할 것 */
.negbox { margin: 10px 0 4px; }
.neg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; margin: 6px 0 8px; }
.neg-grid label { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 500; font-size: 13px; }
.neg-grid label:has(input:checked) { border-color: var(--primary); background: #fff5f6; }
.negbox input[name=negative] { width: 100%; }

/* 스토리보드 */
.sb-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; padding: 16px; }
.sb-side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 10px; }
.sb-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 170px); overflow: auto; }
.sb-item { display: flex; gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px; cursor: pointer; font: inherit; }
.sb-item.active { border-color: var(--primary); background: #fff5f6; }
.sb-cover { width: 56px; height: 36px; flex: none; border-radius: 4px; background: #eef0f3 center/cover no-repeat; }
.sb-item-text { display: flex; flex-direction: column; min-width: 0; }
.sb-item-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.sb-main { min-width: 0; }
#sb-shared-box { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
#sb-shared-box.hidden { display: none; }
.sb-shared-list { max-height: 40vh; }
.sb-shared-tag { color: var(--primary); font-weight: 700; }
.sb-share { flex: none; white-space: nowrap; }
.sbp-box { width: min(1100px, 100%); }
.sbp-acts { display: flex; gap: 6px; flex: none; }
.sbp-refs { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.sbp-ref { width: 64px; height: 64px; border-radius: 6px; background: #eef0f3 center/cover no-repeat; cursor: pointer; border: 1px solid var(--line); }
.sbp-script { white-space: pre-wrap; margin: 6px 0; }
.sbp-cuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 10px 0; }
.sbp-cut { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.sbp-cut .sb-img.empty { cursor: default; }
.sbp-text p { margin: 4px 0 0; }
.sb-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sb-title { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; border-color: transparent; padding: 6px 8px; }
.sb-title:hover, .sb-title:focus { border-color: var(--line); }
.sb-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.sb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.sb-status { padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.sb-status.busy { background: #fff8e6; color: #8a5a00; }
.sb-status.err { background: #fdecec; color: #b42318; }
.sb-settings { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 10px; }
.sb-settings > label { min-width: 160px; }
.sb-settings .pickers { margin: 0; }
.sb-refs { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; margin-bottom: 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; }
.sb-refs .pickers { margin: 0; }
.sb-refs-base { flex: 1; min-width: 260px; }
.sb-refs-base ol.hint { margin: 4px 0 0; padding-left: 18px; }
.sb-refs-base ol.hint li { margin: 2px 0; }
.sb-script { margin-bottom: 12px; }
.sb-script textarea { width: 100%; }
.sb-cuts { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.sb-cut { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.sb-visual { display: flex; flex-direction: column; gap: 6px; }
.sb-img { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #eef0f3 center/cover no-repeat; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sb-img.portrait { aspect-ratio: 9 / 16; width: 60%; margin: 0 auto; }
.sb-img.square { aspect-ratio: 1; width: 80%; margin: 0 auto; }
.sb-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .7); border-radius: 8px; font-weight: 600; color: #8a5a00; }
.sb-hist { display: flex; flex-wrap: wrap; gap: 4px; }
/* 등장인물 사진과 비교한 결과 (컷 이미지 아래) */
.sb-look { line-height: 1.35; }
.sb-look.ok { color: #1a7f37; }
.sb-look.bad { color: #b42318; background: #fff4f2; border: 1px solid #f3c1b9; border-radius: 6px; padding: 4px 6px; }
.sb-look-tail { display: block; color: #8a5a00; margin-top: 2px; }
.linkish { background: none; border: 0; padding: 0; color: #2457c5; text-decoration: underline; cursor: pointer; font: inherit; }
.sb-hist img { width: 44px; height: 30px; object-fit: cover; border-radius: 4px; border: 2px solid transparent; cursor: pointer; opacity: .75; }
.sb-hist img.on { border-color: var(--primary); opacity: 1; }
.sb-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sb-fields textarea, .sb-fields input:not([type=checkbox]) { width: 100%; }
.sb-cut-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sb-no { font-size: 18px; color: var(--primary); }
.sb-cut-head label.inline { display: flex; flex-direction: row; align-items: center; gap: 4px; margin: 0; font-weight: 500; }
.sb-cut-head input[name=seconds] { width: 70px !important; }
.sb-grow { flex: 1; }
.sb-cut-btns { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .sb-layout { grid-template-columns: 1fr; }
  .sb-side { position: static; }
  .sb-cut { grid-template-columns: 1fr; }
}

/* 사용 모델 */
.model-row { margin: -4px 0 12px; display: flex; flex-direction: column; gap: 2px; }
.model-row:empty { display: none; }
.model-fixed { font-size: 13px; color: var(--muted); }
.model-fixed b { color: var(--text); font-weight: 600; margin: 0 4px; }
.model-pick { flex-direction: row !important; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.model-pick select { padding: 5px 8px; font-size: 13px; }
.model-desc { margin-left: 2px; }

/* 멀티참조 태그 점검 */
.tag-warn { margin: 8px 0 4px; padding: 10px 12px; border-radius: 8px; background: #fff8e6; color: #7a4d00; font-size: 13px; line-height: 1.5; }
.tag-warn ul { margin: 4px 0 0; padding-left: 18px; }
.tag-warn li + li { margin-top: 3px; }

/* 스토리보드 영상 */
.sb-videobar { padding: 8px 10px; background: #f7f8fa; border-radius: 8px; }
.sb-videobar label.check { margin: 0 0 0 6px; }
.sb-videobar .sb-vmodel { flex-direction: row; align-items: center; gap: 6px; margin: 0 0 0 6px; font-weight: 500; }
.sb-videobar .sb-vmodel select { width: auto; padding: 4px 6px; font-size: 12px; }
/* 참고 영상으로 만든 컷: 원본 장면 */
.sb-refimg { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--line); border-radius: 6px; background: #fafafa; padding: 3px; cursor: pointer; font: inherit; text-align: left; }
.sb-refimg:hover { border-color: var(--primary); }
.sb-refimg img { width: 84px; border-radius: 4px; display: block; }
.sb-refimg span { font-size: 11px; color: var(--muted); }
.sb-follow { font-size: 12px; color: var(--muted); }
.sb-castmap { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; background: #fafafa; }
.sb-castmap-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sb-castmap-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.sb-castmap-tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 2px 4px; }
.sb-castmap-tbl td { padding: 2px 4px; }
.sb-castmap-tbl td:first-child { white-space: nowrap; }
.sb-castmap-tbl td:nth-child(2) { width: 9em; }
.sb-castmap-tbl input { width: 100%; }
.sb-castmap .hint { margin: 6px 0 0; }
.sb-castmap-tbl input.bad { border-color: #d33; background: #fff3f3; }
.sb-castmap-warn { color: #b42318; margin: 6px 0 0; }
.sb-fromvideo { margin-bottom: 14px; }
.sb-videohint { margin: -4px 0 10px; }
.sb-vid { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px; cursor: pointer; font: inherit; text-align: left; }
.sb-vid:hover { border-color: var(--primary); }
.sb-vthumb { width: 64px; height: 40px; flex: none; border-radius: 4px; background: #222 center/cover no-repeat; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; text-shadow: 0 1px 3px #000; }

/* 글자 넣기 */
.tx-preview { position: relative; width: fit-content; max-width: 100%; margin: 6px auto 0; }
.tx-preview:not(.ready) { width: 100%; }
.tx-preview img { display: none; max-width: 100%; max-height: 460px; border-radius: 8px; cursor: crosshair; user-select: none; touch-action: none; }
.tx-preview.ready img { display: block; }
.tx-preview.ready .tx-empty { display: none; }
.tx-preview.loading img { opacity: .85; }
.tx-empty { padding: 36px 20px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; text-align: center; }
.tx-mark { display: none; position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); pointer-events: none; }
.tx-preview.ready .tx-mark { display: block; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 250px; overflow: auto; padding: 2px; margin-bottom: 12px; }
.font-opt { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 6px; cursor: pointer; text-align: left; font: inherit; }
.font-opt img { display: block; width: 100%; height: 30px; object-fit: contain; object-position: left center; }
.font-opt span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-opt.active { border-color: var(--primary); background: #fff5f6; box-shadow: 0 0 0 1px var(--primary); }
.tx-sliders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tx-sliders input[type=range] { width: 100%; }
.rv { color: var(--primary); font-weight: 700; font-size: 12px; }
input[type=color] { width: 100%; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.finish-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.finish-grid label { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 500; font-size: 13px; }
.finish-grid label small { color: var(--muted); font-weight: 400; }
.finish-grid label:has(input:checked) { border-color: var(--primary); background: #fff5f6; }
.model-row.dim { opacity: .45; }
@media (max-width: 700px) {
  .finish-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tx-sliders { grid-template-columns: 1fr; }
}

/* 만들기 전 예상 시간 · 고품질로 다시 만들기 */
.eta-line { margin: 2px 0 8px; }
.eta-line:empty { display: none; }
.eta-line.eta-long { color: var(--warn); font-weight: 600; }
.job-btns .btn.hq { border-color: #b3cdf5; color: #1a5fd0; }

/* 소리 파일 */
.item .thumb.audio-thumb { display: flex; align-items: center; justify-content: center; font-size: 44px; color: #1a5fd0; background: #eef3fb; }
.audio-box { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 36px 12px; font-size: 56px; color: #1a5fd0; background: #eef3fb; border-radius: 8px; }
.audio-box audio { width: min(520px, 100%); }

/* 보기 창: 장면 훑어보기 */
.vstrip { display: flex; gap: 2px; margin: 8px auto 0; max-width: 100%; }
.vstrip button { flex: 1; aspect-ratio: 16 / 9; min-width: 0; border: 2px solid transparent; border-radius: 4px; padding: 0; cursor: pointer; background-repeat: no-repeat; background-color: #000; }
.vstrip button:hover { border-color: #9cb8e6; }
.vstrip button.on { border-color: var(--primary); }

/* 인물 뽑기: 영상 장면 고르기 */
.cast-scene { margin-bottom: 12px; }
.cast-video { display: block; width: 100%; max-height: 300px; background: #000; border-radius: 8px; }
.cast-strip { margin: 6px 0 8px; }
.cast-t { max-width: 160px; }
form[data-form=cast] .radio-row, form[data-form=cast] .radio-col { margin-bottom: 12px; }

/* 파일 고르기 창: 등장인물 */
.pick-chars, .pick-files-label { grid-column: 1 / -1; }
.pick-chars { display: flex; flex-direction: column; gap: 8px; border-bottom: 1px dashed var(--line); padding-bottom: 10px; }
.pick-char { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 10px; align-items: center; }
.pick-char > .muted { grid-column: 1; }
.pick-char-imgs { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.pick-char-imgs button { flex: none; width: 76px; height: 96px; border: 1px solid var(--line); border-radius: 6px; background: #f0f1f3 center/cover no-repeat; cursor: pointer; position: relative; padding: 0; }
.pick-char-imgs button:hover { border-color: var(--primary); }
.pick-char-imgs button span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; padding: 1px 2px; border-radius: 0 0 5px 5px; }

/* 등장인물 탭 */
.ch-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 170px); overflow: auto; }
.ch-item { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px; cursor: pointer; font: inherit; }
.ch-item:hover { border-color: #c9ced6; }
.ch-item.active { border-color: var(--primary); background: #fdf3f5; }
.ch-cover { flex: none; width: 52px; height: 52px; border-radius: 6px; background: #eceef1 center/cover no-repeat; }
.ch-meta { display: flex; flex-direction: column; min-width: 0; }
.ch-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-st { font-size: 11px; color: #1a5fd0; }
.ch-st.error { color: var(--err); }
.ch-form { max-width: 720px; display: flex; flex-direction: column; gap: 10px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.radio-col { display: flex; flex-direction: column; gap: 4px; }
.ch-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ch-head h2 { margin: 0; }
.ch-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.ch-steps span { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f0f1f3; color: var(--muted); }
.ch-steps span.done { background: #e5f5ea; color: var(--ok); }
.ch-steps span.on { background: #e6f0ff; color: #1a5fd0; font-weight: 700; }
.ch-sheet { margin: 12px 0; }
.ch-sheet img { width: 100%; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.ch-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 12px 0; }
.ch-img { position: relative; display: flex; flex-direction: column; gap: 4px; font-size: 12px; text-align: center; color: var(--muted); }
.ch-img-thumb { aspect-ratio: 3 / 4; border: 1px solid var(--line); border-radius: 8px; background: #f0f1f3 center/cover no-repeat; cursor: zoom-in; padding: 0; }
.ch-img .job-x { position: absolute; top: 2px; right: 2px; background: rgba(255, 255, 255, .85); }
.ch-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-use, .ch-manage { margin-top: 14px; }
.ch-desc-box { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ch-desc-box .btn { align-self: flex-start; }

/* 설정: 개인 API 토큰 */
.tok-new input { flex: 1; }
.tok-once { margin: 10px 0; padding: 10px; border: 1px solid #f0c36d; background: #fff8e6; border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.tok-once code { word-break: break-all; font-size: 13px; background: #fff; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); }
.tok-once .btn { align-self: flex-start; }
.tok-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tok-row .btn { margin-left: auto; }
.tok-ex { font-size: 12px; white-space: pre-wrap; word-break: break-all; background: #f6f7f9; padding: 8px; border-radius: 6px; }
@media (max-width: 760px) { .pick-char { grid-template-columns: 1fr; } .pick-char-imgs { grid-column: 1; grid-row: auto; } }
