/* 매칭 제작 스튜디오 (docs/MATCHING_MODULE_PLAN.md §5-7) — 단독 스타일시트(common.css 미사용).
   유머 스튜디오 레이아웃(좌: 트리 / 우: 탭)을 다크·컴팩트 운영자 UI 로 옮긴 것. 노트북 폭(≥1024) 기준. */

:root {
  --bg: #14161a; --bg-2: #1b1e24; --bg-3: #22262e; --line: #2c313a; --line-2: #3a404b;
  --fg: #e6e8ec; --fg-2: #aab1bd; --fg-3: #737b88;
  --accent: #5b9cf6; --accent-2: #3b76d0; --ok: #46b36b; --warn: #f0a63a; --err: #e5534b; --violet: #a78bfa; --pink: #f472b6;
}
* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.45 -apple-system, "Segoe UI", "Malgun Gothic", Roboto, sans-serif; }
a { color: var(--accent); }
button {
  font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  background: var(--bg-3); color: var(--fg); border: 1px solid var(--line-2);
}
button:hover { background: #2a2f38; border-color: #4a5160; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
button.primary:hover { background: var(--accent); }
button.danger { color: #ff8a80; border-color: #6b3a37; }
button.danger:hover { background: #3a2321; }
button.cost { border-color: #7a5a1e; color: #ffd28a; }
button.picked { background: #1f3a2a; border-color: #2e7d4a; color: #8be0a8; cursor: default; }
input, textarea, select {
  font: inherit; font-size: 12px; color: var(--fg); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 6px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.4; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--fg-3); font-size: 11px; }
.err { color: #ff8a80; }
.up { color: #8be0a8; } .down { color: #ff8a80; }

/* ── 헤더 ── */
.studio-header {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.studio-header-left, .studio-header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.studio-header h1 { margin: 0; font-size: 16px; white-space: nowrap; }
.studio-back { text-decoration: none; font-size: 18px; color: var(--fg-2); }
.studio-header select { max-width: 44vw; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--bg-3); color: var(--fg-2); }
.badge.ok { background: #1f3a2a; color: #8be0a8; }
.badge.warn { background: #3d2e12; color: #ffd28a; }
.badge.hot { background: #4a2a12; color: #ffb86b; }
.badge.auto { background: #2a2350; color: #c4b5fd; }
.badge.manual { background: var(--bg-3); color: var(--fg-2); }
.badge.st-ongoing { background: #16324f; color: #90caf9; }
.badge.st-planning { background: #3d2e12; color: #ffd28a; }
.badge.st-completed { background: #2a2e36; color: #aab1bd; }
.badge.st-halted { background: #4a1f1d; color: #ff8a80; }

/* ── 관리자 키 ── */
.key-panel { padding: 10px 14px; background: #2b2412; border-bottom: 1px solid #5a4a1e; }
.key-panel form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-panel input { min-width: 280px; }
.key-panel .hint { margin: 6px 0 0; color: var(--fg-3); font-size: 11px; }
.key-error { color: #ffb86b; font-size: 12px; }

/* ── 레이아웃 ── */
.studio-main { display: flex; align-items: stretch; min-height: calc(100vh - 48px); }
.tree-pane {
  width: 320px; min-width: 260px; border-right: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 46px; max-height: calc(100vh - 46px); overflow-y: auto;
}
.pane-title { padding: 8px 12px; font-weight: 700; font-size: 12px; color: var(--fg-3); }
.detail-pane { flex: 1; min-width: 0; padding: 10px 16px 60px; }

/* ── 좌측 트리 ── */
.unit-tree { padding: 0 8px 16px; display: flex; flex-direction: column; gap: 8px; }
.tree-date { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tree-daily { padding: 7px 10px; background: var(--bg-3); cursor: pointer; border-left: 3px solid transparent; }
.tree-daily.none { cursor: default; opacity: .75; }
.tree-daily:hover:not(.none) { border-left-color: var(--violet); }
.tree-daily.active { border-left-color: var(--violet); background: #262a3a; }
.td-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.td-date { font-weight: 700; }
.td-meta { color: var(--fg-3); font-size: 11px; }
.td-title { color: var(--fg-2); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-link { margin-left: auto; font-size: 11px; text-decoration: none; color: #ff8a80; font-weight: 700; }
.tree-meeting { display: flex; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); cursor: pointer; border-left: 3px solid transparent; background: var(--bg-2); }
.tree-meeting:hover { border-left-color: var(--accent); }
.tree-meeting.active { border-left-color: var(--accent); background: #1f2a3d; }
.tm-thumb { width: 36px; height: 48px; flex: 0 0 36px; border-radius: 4px; background: #0d0f12; overflow: hidden; }
.tm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-body { min-width: 0; flex: 1; }
.tm-head { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-sub { color: var(--fg-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; padding: 0 6px; border-radius: 8px; font-size: 10px; font-weight: 700; background: var(--bg-3); color: var(--fg-2); vertical-align: middle; }
.tag.final { background: #4a2a12; color: #ffb86b; }
.tag.skip { background: #2a2e36; color: #90a4ae; }
.tag.warn { background: #3d2e12; color: #ffd28a; }
.stage-chips { display: flex; gap: 2px; margin-top: 4px; font-size: 11px; line-height: 1; }
.stage-chips span { width: 14px; text-align: center; cursor: default; }
.chip-none { color: #454b56; }
.chip-PENDING { color: #f9c74f; }
.chip-RUNNING { color: var(--accent); }
.chip-REVIEW { color: var(--warn); font-weight: 700; }
.chip-SCHEDULED { color: var(--violet); }
.chip-APPROVED { color: var(--ok); }
.chip-FAILED { color: var(--err); font-weight: 700; }
.chip-SKIPPED { color: #90a4ae; }

/* ── 시즌 패널 ── */
.season-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); margin-bottom: 10px; }
.season-panel > summary { cursor: pointer; padding: 8px 12px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.season-panel > summary::-webkit-details-marker { display: none; }
.season-panel > summary::before { content: "▸"; color: var(--fg-3); }
.season-panel[open] > summary::before { content: "▾"; }
.season-panel > summary .muted { font-weight: 400; }
#season-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.participants { display: flex; flex-direction: column; gap: 6px; }
.part-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.part-label { width: 18px; padding-top: 22px; color: var(--fg-3); font-weight: 700; }
.part { text-align: center; width: 60px; }
.part-portrait { width: 48px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); cursor: pointer; display: block; margin: 0 auto; }
.part-portrait.none { background: var(--bg-3); }
.part-name { font-size: 11px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cast-table th, .cast-table td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: middle; }
.cast-table th { background: var(--bg-3); color: var(--fg-2); font-weight: 600; }
.cast-portrait { width: 32px; height: 42px; object-fit: cover; border-radius: 4px; cursor: pointer; display: block; }
.budget { font-size: 12px; color: var(--fg-2); padding: 2px 8px; border-radius: 8px; background: var(--bg-3); }
.budget.over { color: #ffb86b; background: #4a2a12; }

/* ── 우측 탭·본문 ── */
.unit-title { font-size: 15px; font-weight: 700; margin: 4px 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.unit-title .ut-sub { font-size: 12px; font-weight: 400; color: var(--fg-3); }
.stage-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 10px; flex-wrap: wrap; }
.stage-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 0;
  padding: 7px 10px; color: var(--fg-2); font-weight: 500; white-space: nowrap;
}
.stage-tabs button:hover { background: var(--bg-3); }
.stage-tabs button.active { border-bottom-color: var(--accent); color: #fff; font-weight: 700; }
.stage-tabs .tab-glyph { font-size: 11px; margin-left: 2px; }
.tab-content { display: flex; flex-direction: column; gap: 10px; }

.ap-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.st-pill { padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; background: var(--bg-3); color: var(--fg-2); }
.st-PENDING { background: #3d2e12; color: #f9c74f; }
.st-RUNNING { background: #16324f; color: #90caf9; }
.st-REVIEW { background: #4a2a12; color: #ffb86b; }
.st-SCHEDULED { background: #2a2350; color: #c4b5fd; }
.st-APPROVED { background: #1f3a2a; color: #8be0a8; }
.st-FAILED { background: #4a1f1d; color: #ff8a80; }
.st-SKIPPED { background: #2a2e36; color: #90a4ae; }
.st-planning { background: #3d2e12; color: #ffd28a; } .st-ongoing { background: #16324f; color: #90caf9; }
.st-completed { background: #2a2e36; color: #aab1bd; } .st-halted { background: #4a1f1d; color: #ff8a80; }
.notice { font-size: 12px; color: var(--fg-2); background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 6px; padding: 6px 10px; }
.empty-note { color: var(--fg-3); font-size: 13px; padding: 20px 0; text-align: center; }
.kv-json { font-size: 12px; color: var(--fg-2); }
.kv-json b { color: var(--fg); }
.kv { display: flex; gap: 8px; font-size: 12px; margin-top: 4px; }
.kv-table { border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.kv-table th, .kv-table td { padding: 2px 10px 2px 0; text-align: left; color: var(--fg-2); white-space: nowrap; }
.kv-table th { color: var(--fg-3); font-weight: 600; }
.kv b { color: var(--fg-2); flex: 0 0 auto; }

/* 산출물 카드 */
.art-card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); padding: 8px 12px; }
.art-card.selected { border-color: #2e7d4a; box-shadow: 0 0 0 1px #2e7d4a inset; }
.ac-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--fg-2); }
.ac-head .ac-model { font-weight: 700; color: var(--fg); }
.ac-flag { padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 700; background: var(--bg-3); }
.ac-flag.SELECTED { background: #1f3a2a; color: #8be0a8; }
.ac-flag.CANDIDATE { background: var(--bg-3); color: var(--fg-2); }
.ac-flag.REJECTED, .ac-flag.DELETED { background: #4a1f1d; color: #ff8a80; }
.ac-flag.SUPERSEDED { background: #2a2350; color: #c4b5fd; }
.ac-cost { color: var(--pink); font-weight: 700; }
.ac-body { margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.ac-media img, .ac-media video { max-width: 260px; max-height: 340px; border-radius: 6px; background: #000; display: block; }
.ac-media img { cursor: zoom-in; }
.ac-actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.ac-actions a { text-decoration: none; }
.ep-title { font-size: 14px; font-weight: 700; margin-top: 6px; }
.ep-body { font-size: 13px; line-height: 1.55; color: var(--fg); background: var(--bg-3); border-radius: 6px; padding: 8px 10px; margin-top: 6px; max-height: 360px; overflow-y: auto; }
details.prompt-box { margin-top: 6px; font-size: 12px; }
details.prompt-box summary { cursor: pointer; color: var(--accent); }
details.prompt-box pre { background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-top: 4px; max-height: 300px; overflow-y: auto; font-size: 12px; }
.card-sum { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--fg-2); margin-top: 6px; }
.card-sum b { color: var(--fg); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* 합본 슬롯 스트립 */
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.strip-item { flex: 0 0 120px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2); overflow: hidden; }
.strip-item.skip { opacity: .6; }
.strip-thumb { height: 80px; background: #0d0f12; }
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-cap { padding: 4px 6px; font-size: 11px; line-height: 1.35; }

/* 관리자 패널 */
.admin-panel { border-top: 2px solid var(--accent-2); background: #182030; border-radius: 0 0 8px 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.admin-panel .ap-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.admin-panel .ap-row > label:only-child, .admin-panel .ap-row > label + textarea { width: 100%; }
.admin-panel label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--fg-2); }
.admin-panel .ap-row textarea { flex: 1 1 100%; }

/* 미리보기 모달 · 플래시 */
.preview-modal { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 100; display: flex; align-items: center; justify-content: center; }
.preview-modal img { max-width: 92vw; max-height: 90vh; object-fit: contain; }
.preview-close { position: absolute; top: 10px; right: 14px; font-size: 28px; background: none; border: none; color: #fff; }
.flash {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 90;
  background: #263246; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 12px; border: 1px solid var(--accent-2);
  transition: opacity .2s, transform .2s; max-width: 80vw;
}
.flash.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .studio-main { flex-direction: column; }
  .tree-pane { width: auto; max-height: 240px; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .studio-header select { max-width: 60vw; }
}
