:root {
  --bg: #15171c; --panel: #1d2027; --panel2: #252932; --line: #333845;
  --text: #e6e8ee; --muted: #8b92a3; --accent: #4f8cff; --accent2: #2fbf8a;
  --warn: #f0a63a; --err: #ef5b5b; --ep: #6d5bd0; --sel: #ffd84d;
  --c-prep: #3f8f6b; --c-manip: #3b6fc4; --c-verify: #b0703a; --c-exc: #a04a6a;
  font-size: 13px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
body.no-kor .kor-only { display: none !important; }   /* 국문 산출 꺼짐 (설정) */
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* top bar */
.topbar { height: 46px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; }
.brand .ver { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
.actions { display: flex; gap: 6px; }
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel2); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #4a5163; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent { background: var(--accent2); border-color: var(--accent2); color: #08130e; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .45; cursor: default; }

/* layout */
.layout { height: calc(100% - 46px); display: grid; gap: 6px; padding: 6px;
  grid-template-columns: minmax(420px, 1fr) 400px 240px;
  grid-template-rows: minmax(260px, 1fr) 180px;
  grid-template-areas: "video info parts" "tl tl tl"; }
.save-state { color: var(--muted); font-size: 11px; align-self: center; min-width: 70px; }
/* 웹 버전: 로그인 사용자 · 영상 상태 */
a.btn { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; }
.who { color: var(--muted); font-size: 12px; align-self: center; padding-left: 6px; border-left: 1px solid #333a48; }
.status-box { display: inline-flex; align-items: center; gap: 6px; }
.status-box:empty { display: none; }
.st { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.st-todo { background: #3a3f4b; color: #c9ced9; }
.st-working { background: #1f4fa0; color: #dce8ff; }
.st-review { background: #8a5a00; color: #ffe9bf; }
.st-done { background: #1f7a4d; color: #d6f5e5; }
.actions select { max-width: 260px; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 0; min-width: 0; }
.video-pane { grid-area: video; display: flex; flex-direction: column; }
.info-pane { grid-area: info; display: flex; flex-direction: column; }
.parts-pane { grid-area: parts; display: flex; flex-direction: column; }
.timeline-pane { grid-area: tl; display: flex; flex-direction: column; }

/* video */
.video-wrap { position: relative; flex: 1; min-height: 0; background: #000; border-radius: 8px 8px 0 0; overflow: hidden; }
.video-wrap.drag { outline: 2px dashed var(--accent); outline-offset: -6px; }
video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
/* 영상 위 스파스 미리보기 (우측 상단) */
.sp-preview { position: absolute; top: 10px; right: 10px; max-width: 46%; padding: .6em .8em; border-radius: 6px;
  background: rgba(10, 12, 16, .62); color: #fff; font-size: 14px; line-height: 1.45; pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.8); }
.sp-preview.bg-white { background: rgba(255,255,255,.96); color: #111; text-shadow: none; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.sp-preview .pv-h { font-family: Consolas, monospace; font-size: .85em; opacity: .8; }
.sp-preview .pv-task { font-weight: 700; font-size: 1.1em; margin: .1em 0 .3em; }
.sp-preview .pv-task .ew { font-weight: 400; opacity: .8; font-size: .85em; margin-left: .4em; }
.sp-preview table { border-collapse: collapse; margin-bottom: .35em; }
.sp-preview td { padding: 0 .6em .05em 0; vertical-align: top; }
.sp-preview td.k { opacity: .7; white-space: nowrap; }
.sp-preview .pv-desc { border-top: 1px solid currentColor; border-color: rgba(127,127,127,.5); padding-top: .3em; }
.sp-preview .pv-desc .kor { opacity: .85; margin-top: .15em; }
/* 이동 경로: [출발] → [부품] → [도착] */
.sp-preview .pv-route { display: flex; align-items: center; gap: .35em; margin: .2em 0 .45em; }
.sp-preview .pv-route .arr { font-size: 1.4em; font-weight: 700; opacity: .8; padding-top: .5em; }
.sp-preview .pv-fig { margin: 0; width: 5.6em; display: flex; flex-direction: column; align-items: center; }
.sp-preview .pv-fig .tag { align-self: stretch; text-align: center; font-size: .75em; font-weight: 700; color: #fff; border-radius: 4px 4px 0 0; padding: .05em 0; }
.sp-preview .pv-fig.from .tag { background: #2f7de1; }
.sp-preview .pv-fig.part .tag { background: #7a7a7a; }
.sp-preview .pv-fig.to   .tag { background: #1f9d55; }
.sp-preview .pv-fig img, .sp-preview .pv-fig .noimg { display: block; width: 5.6em; height: 4.6em; object-fit: contain; background: #fff; border-radius: 0 0 4px 4px; box-sizing: border-box; }
.sp-preview .pv-fig.from img, .sp-preview .pv-fig.from .noimg { border: 2px solid #2f7de1; border-top: 0; }
.sp-preview .pv-fig.part img, .sp-preview .pv-fig.part .noimg { border: 2px solid #7a7a7a; border-top: 0; }
.sp-preview .pv-fig.to img,   .sp-preview .pv-fig.to .noimg   { border: 2px solid #1f9d55; border-top: 0; }
.sp-preview .pv-fig .noimg { display: flex; align-items: center; justify-content: center; color: #888; font-weight: 700; }
.sp-preview .pv-fig .noimg span { font-size: 1.6em; }
.sp-preview .pv-fig figcaption { font-size: .62em; line-height: 1.2; margin-top: .2em; text-align: center; word-break: break-all; font-weight: 600; }
.sp-preview .pv-gap { opacity: .75; font-style: italic; }
.pv-ctrl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pv-ctrl .chk { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.pv-ctrl input[type=range] { width: 56px; }
.controls { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.icon { min-width: 38px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; }
.icon.play { min-width: 48px; background: var(--accent); border-color: var(--accent); color: #fff; }
.timecode { font-family: Consolas, monospace; font-size: 14px; padding: 0 6px; }
.fps input { width: 64px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
select { background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; }

/* tabs / info */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 8px; background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff; font-size: 11px; }
.badge:empty { display: none; }
.tab-body { flex: 1; overflow: auto; padding: 10px 12px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.card.selected { border-color: var(--sel); }
.card h3 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.card h3 .id { font-family: Consolas, monospace; color: var(--sel); }
.card h3 .tools { margin-left: auto; display: flex; gap: 4px; }
.row { display: grid; grid-template-columns: 64px 1fr; gap: 6px; align-items: center; margin: 5px 0; }
.row > label { color: var(--muted); font-size: 12px; }
.row input[type=number], .row input[type=text], .row select, .row textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
.row.times { grid-template-columns: 64px 1fr 1fr auto; }
.times .dur { color: var(--muted); font-family: Consolas, monospace; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
label.chk { display: inline-flex; gap: 4px; align-items: center; color: var(--text); font-size: 12px; cursor: pointer; margin-right: 10px; }
label.chk input { margin: 0; }
.row .inline select { flex: 1; }
.row.wide { grid-template-columns: 110px 1fr; min-width: 420px; }
.slot { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border: 1px dashed var(--line); border-radius: 6px; cursor: pointer; min-height: 32px; }
.slot.active { border: 1px solid var(--accent); box-shadow: 0 0 0 2px rgba(79,140,255,.25); }
.slot img { width: 34px; height: 26px; object-fit: cover; border-radius: 3px; }
.slot .nm { font-family: Consolas, monospace; font-size: 12px; flex: 1; }
.slot .clr { margin-left: auto; color: var(--muted); border: 0; background: transparent; cursor: pointer; }
.slot select { flex: 1; min-width: 0; }
/* episode 부품 여러 개 */
.slot.multi { flex-wrap: wrap; }
.slot.multi .chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; }
.slot.multi .chip .nm { flex: none; }
.slot.multi .chip .clr { margin-left: 2px; }
.task-info { font-size: 11px; color: var(--muted); margin: -2px 0 6px 70px; line-height: 1.4; }
.desc { margin-top: 8px; }
.desc .lang { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin: 6px 0 2px; }
.desc .lang .lock { color: var(--warn); }
.desc textarea { width: 100%; min-height: 46px; resize: vertical; background: #12141a; border: 1px solid var(--line); border-radius: 5px; padding: 6px; line-height: 1.45; }
.desc textarea.manual { border-color: var(--warn); }
.missing { color: var(--warn); font-size: 11px; margin-top: 4px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 12px; margin: 6px 0; }
.empty-info { color: var(--muted); line-height: 1.7; }
.empty-info kbd, .help kbd { background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: Consolas, monospace; font-size: 11px; }
.sparse-nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 10px; }
.sparse-nav button { font-family: Consolas, monospace; font-size: 11px; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.sparse-nav button.on { border-color: var(--sel); color: var(--sel); }
.sparse-nav button.bad { border-color: var(--warn); }
.ctx-menu { position: fixed; z-index: 1000; min-width: 200px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.ctx-menu .ctx-h { padding: 4px 8px 6px; font-size: 11px; opacity: .7; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-family: Consolas, monospace; }
.ctx-menu .ctx-empty { padding: 6px 8px; font-size: 12px; opacity: .7; }
.ctx-item { display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 8px; border: 0; border-radius: 4px; background: none; color: inherit; font-family: Consolas, monospace; font-size: 12px; text-align: left; cursor: pointer; }
.ctx-item:hover { background: var(--sel); color: #fff; }
.ctx-item.on .c { color: var(--sel); font-weight: 600; }
.ctx-item.on:hover .c { color: #fff; }
.ctx-item .c { flex: 1; }
.ctx-item .src { font-size: 10px; opacity: .6; }
.ctx-item .qk { display: inline-block; min-width: 14px; padding: 0 3px; border-radius: 3px; background: var(--line); font-size: 10px; text-align: center; }
.row.quick { align-items: flex-start; }
.quick-list { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.qbtn { font-family: Consolas, monospace; font-size: 11px; padding: 2px 6px; border-radius: 4px; border: 1px dashed var(--sel); background: var(--panel); color: inherit; cursor: pointer; }
.qbtn:hover { background: var(--sel); color: #fff; }
.qbtn.on { border-style: solid; color: var(--sel); font-weight: 600; }
.qbtn.on:hover { color: #fff; }
.qbtn .qk { display: inline-block; min-width: 12px; margin-right: 4px; padding: 0 3px; border-radius: 3px; background: var(--line); font-size: 10px; text-align: center; }

/* list */
.list-ep { margin-bottom: 12px; }
.list-ep > .h { font-weight: 600; margin-bottom: 4px; cursor: pointer; }
.list-sp { display: grid; grid-template-columns: 92px 110px 1fr; gap: 6px; font-size: 12px; padding: 3px 0; border-top: 1px solid var(--line); cursor: pointer; }
.list-sp:hover, .list-ep > .h:hover { color: var(--sel); }
.mono { font-family: Consolas, monospace; }
.issue { font-size: 12px; padding: 4px 6px; border-left: 3px solid var(--warn); background: rgba(240,166,58,.08); margin: 3px 0; cursor: pointer; }
.issue.err { border-left-color: var(--err); background: rgba(239,91,91,.08); }

/* parts (Info 오른쪽 세로 목록, 이미지는 잘림 없이 원본 비율) */
.parts-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); gap: 6px; }
.parts-target { font-size: 11px; color: var(--accent); padding: 4px 8px; min-height: 22px; }
.parts-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.pgroup { font-size: 11px; color: var(--muted); margin: 8px 0 4px; font-family: Consolas, monospace; }
.pcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; cursor: pointer; margin-bottom: 6px; }
.pcard:hover { border-color: var(--accent); }
.pcard.chosen { border: 2px solid var(--sel); }
.pcard.dim { opacity: .3; }
.pcard img { display: block; width: 100%; height: auto; max-height: 170px; object-fit: contain; background: #000; }
.pcard .n { padding: 4px 6px; font-family: Consolas, monospace; font-size: 11px; font-weight: 600; word-break: break-all; }

/* timeline */
.tl-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--line); font-size: 12px; }
#timeline { flex: 1; width: 100%; min-height: 0; display: block; cursor: default; }

/* modal / toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; max-width: 860px; max-height: 86vh; overflow: auto; min-width: 380px; }
.modal-box h2 { margin: 0 0 10px; font-size: 16px; }
.modal-box .foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.modal-box img.big { max-width: 800px; max-height: 70vh; display: block; margin: 0 auto; }
.help table { border-collapse: collapse; width: 100%; }
.help td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #000c; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }
