/* AI공방 — 밝은 카드형 화면(기본) + 어두운 화면 */
:root {
  --bg: #eef1f6; --card: #ffffff; --card2: #f5f7fb; --card3: #eceff5; --line: #e3e7ef; --line2: #d4dae5;
  --text: #1b2130; --muted: #6b7489; --dim: #98a0b3;
  --accent: #2f6bff; --accent-h: #1f5af0; --accent-soft: #e8efff; --ai: #7b5cff; --ai2: #b04cff;
  --ok: #17a673; --warn: #d98a00; --danger: #e5484d;
  --c-video: #3d6fe0; --c-image: #2f8f86; --c-text: #f2a516; --c-oimg: #8b5cf6; --c-audio: #1fa37a;
  --tl-bg: #f7f8fb; --tl-lane: #ffffff; --tl-ruler: #f3f5f9; --tl-tick: #c5ccd8; --tl-label: #7a8296;
  --shadow: 0 1px 2px rgba(20,30,60,.06), 0 4px 16px rgba(20,30,60,.05);
  --input: #f6f8fb; --kbd: #f1f3f7;
  --radius: 14px;
  color-scheme: light;
}
[data-theme=dark] {
  --bg: #0e1015; --card: #171a21; --card2: #1d212a; --card3: #252a35; --line: #2a303c; --line2: #363d4b;
  --text: #e9ecf2; --muted: #8e97a9; --dim: #6b7385;
  --accent: #4f8cff; --accent-h: #6a9dff; --accent-soft: rgba(79,140,255,.16);
  --tl-bg: #13161c; --tl-lane: #1a1e26; --tl-ruler: #161a22; --tl-tick: #3a4150; --tl-label: #9aa3b5;
  --shadow: 0 2px 10px rgba(0,0,0,.35);
  --input: #10131a; --kbd: #252a35;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Pretendard, 'Malgun Gothic', system-ui, sans-serif; display: grid; grid-template-rows: 54px minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); overflow: hidden; padding: 0 8px 8px; gap: 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--card); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 12px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover { background: var(--card2); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-h); }
button.soft { background: var(--card); border-color: var(--line); font-weight: 600; font-size: 13px; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--card3); color: var(--text); }
button.ai { background: linear-gradient(135deg, var(--ai), var(--ai2)); border: 0; color: #fff; font-weight: 700; }
button.icon { padding: 6px; min-width: 32px; min-height: 32px; }
button.sm { padding: 5px 10px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--accent); padding: 0 4px; text-decoration: underline; }
button.wide { width: 100%; padding: 10px; }
.ic { flex: none; display: block; }
input, select, textarea { background: var(--input); border: 1px solid var(--line2); border-radius: 9px; padding: 6px 9px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: 0; box-shadow: none; }
input[type=color] { padding: 0; width: 34px; height: 30px; border: 1px solid var(--line2); background: none; }
input[type=checkbox] { accent-color: var(--accent); }
kbd { background: var(--kbd); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; font-family: inherit; }
code { background: var(--card3); padding: 1px 5px; border-radius: 5px; font-size: 12px; color: var(--muted); }
.dim { color: var(--muted); } .small { font-size: 12px; } .spacer { flex: 1; }
.hint { color: var(--muted); font-size: 13px; margin: 0 2px 10px; }
[hidden] { display: none !important; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }

/* 상단 */
.topbar { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.brand { white-space: nowrap; flex: none; display: flex; align-items: center; gap: 7px; cursor: pointer; margin-right: 6px; user-select: none; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--ai2)); display: grid; place-items: center; color: #fff; }
.brand b { font-size: 18px; letter-spacing: -.4px; }
.brand .ai-badge { font-style: normal; font-weight: 800; font-size: 11px; color: #fff; background: linear-gradient(135deg, var(--ai), var(--ai2)); padding: 1px 6px; border-radius: 99px; }
.projname { background: transparent; border-color: transparent; font-size: 15px; font-weight: 700; width: 240px; }
.projname:hover { border-color: var(--line2); background: var(--card); }
.savestate { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pillgroup { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 2px; }
.pillgroup button { min-width: 30px; min-height: 30px; }

/* 작업 영역 */
.workspace { display: grid; grid-template-columns: 64px 290px minmax(0, 1fr) 300px; gap: 8px; min-height: 0; }
.rail { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; overflow-y: auto; scrollbar-width: none; }
.rail button { flex-direction: column; gap: 2px; padding: 6px 2px; flex: none; border: 0; background: transparent; color: var(--muted); border-radius: 12px; font-size: 11px; font-weight: 600; }
.rail button:hover { background: var(--card); color: var(--text); }
.rail button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.rail button.ai-tab.on { color: var(--ai); }
.left, .right { min-height: 0; overflow-y: auto; overflow-x: hidden; }
.left { display: flex; flex-direction: column; }
.right { padding: 16px; }
.tab { padding: 14px; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h3 { margin: 0; font-size: 16px; }

.dropzone { border: 1.5px dashed var(--line2); border-radius: 12px; padding: 16px 12px; text-align: center; transition: .15s; color: var(--muted); display: grid; justify-items: center; gap: 6px; background: var(--card2); }
.dropzone p { font-size: 12.5px; margin: 0; }
.dropzone p span { font-size: 11.5px; color: var(--dim); }
.dropzone.over, body.dragging-file .dropzone { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.medialist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.mcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: grab; position: relative; transition: .12s; }
.mcard:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mcard .thumb { aspect-ratio: 16/9; background: #1a1d25 center/cover no-repeat; display: grid; place-items: center; font-size: 24px; color: #8a93a8; position: relative; }
.mcard .thumb .dur { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.65); font-size: 11px; padding: 0 5px; border-radius: 4px; color: #fff; }
.mcard .thumb .kind { position: absolute; left: 4px; top: 4px; font-size: 10px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; }
.mcard .nm { font-size: 12px; padding: 6px 8px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.mcard .add { position: absolute; right: 5px; top: 5px; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 7px; background: var(--accent); border: 0; color: #fff; opacity: 0; font-weight: 700; }
.mcard:hover .add { opacity: 1; }
.mcard .status { font-size: 11px; color: var(--warn); padding: 0 8px 6px; }
.mcard.missing { border-color: var(--danger); }
.mcard.missing .status { color: var(--danger); }
.mcard .relink { margin: 0 8px 8px; padding: 3px 8px; font-size: 12px; background: var(--danger); border: 0; color: #fff; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.textpresets { display: grid; grid-template-columns: 1fr; gap: 10px; }
.tpreset { border: 1px solid var(--line); border-radius: 12px; background: #20242e; height: 84px; display: grid; place-items: center; cursor: grab; position: relative; overflow: hidden; transition: .12s; }
.tpreset:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tpreset span.lbl { position: absolute; left: 8px; top: 6px; font-size: 11px; color: #c6ccda; }

/* 미리보기 */
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.stagewrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 14px; background: var(--card2); }
.stage { position: relative; background: #000; box-shadow: 0 8px 30px rgba(10,15,30,.25); overflow: hidden; border-radius: 4px; }
.stage .pv-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; }
.transport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); }
.transport .tleft { display: flex; align-items: center; gap: 4px; }
.transport .tmid { display: flex; align-items: center; gap: 8px; }
.transport .tright { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.transport .play { width: 40px; height: 40px; border-radius: 50%; background: var(--text); border: 0; color: var(--card); }
.transport .play:hover { background: var(--accent); color: #fff; }
.time { font-variant-numeric: tabular-nums; font-size: 13.5px; font-weight: 600; color: var(--accent); }
.time.dim { color: var(--muted); font-weight: 500; }
.reslabel { white-space: nowrap; }

/* 속성 패널 */
.props h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.props h3 .chip { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; color: #fff; }
.chip.clip { background: var(--c-video); } .chip.text { background: var(--c-text); color: #2b1d00 !important; } .chip.image { background: var(--c-oimg); } .chip.audio { background: var(--c-audio); }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12px; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > input[type=number] { min-width: 0; width: 0; flex: 1 1 0; }
.row > input[type=range] { flex: 1; min-width: 90px; }
.seg { display: flex; background: var(--card3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; border-radius: 8px; background: none; padding: 5px 10px; flex: 1; color: var(--muted); font-size: 13px; }
.seg button:hover { background: var(--card); color: var(--text); }
.seg button.on { background: var(--card); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { padding: 5px 4px; font-size: 12.5px; min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pair label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.pair input { width: 100%; }
.props select { width: 100%; }
.props textarea { width: 100%; resize: vertical; min-height: 70px; }
.props .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.props .actions button { font-size: 13px; }
.props .danger { color: var(--danger); }
.props .info { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.props .info p { margin: 0 0 6px; color: var(--text); }
.props .info ul { margin: 4px 0 0; padding-left: 18px; }
.props .info li { margin: 3px 0; }
.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 18px 8px 16px; color: var(--muted); font-size: 12.5px; }
.empty-state .ic { color: var(--dim); }
.empty-state b { color: var(--text); font-size: 15px; }

/* 타임라인 */
.timeline-area { min-width: 0; height: clamp(230px, 35vh, 390px); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tl-toolbar { display: flex; align-items: center; gap: 2px; padding: 5px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; row-gap: 4px; }
.tl-toolbar button.labeled { font-size: 12.5px; padding: 5px 9px; font-weight: 600; }
.tl-toolbar input[type=range] { width: 110px; }
.tl-toolbar .toggle.on { color: var(--accent); background: var(--accent-soft); }
.tsep { width: 1px; height: 20px; background: var(--line2); margin: 0 5px; }
.timeline { flex: 1; min-height: 0; min-width: 0; display: flex; background: var(--tl-bg); }
.tl-labels { width: 100px; flex: none; border-right: 1px solid var(--line); background: var(--card); overflow: hidden; position: relative; }
.tl-labels-in { will-change: transform; }
.tl-label { display: flex; align-items: center; justify-content: space-between; gap: 2px; padding: 0 4px 0 9px; font-size: 11.5px; color: var(--tl-label); font-weight: 700; box-sizing: border-box; }
.tl-label .lname { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; }
.tl-label.layer { font-size: 11px; border-radius: 6px; }
.tl-label.layer:hover { background: var(--tl-lane); }
.tl-label.off .lname { opacity: .45; text-decoration: line-through; }
.tl-hbtns { display: flex; gap: 1px; }
.tl-hbtn { all: unset; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: var(--tl-label); cursor: pointer; }
.tl-hbtn:hover { background: var(--accent-soft); color: var(--accent); }
.tl-label.off .tl-hbtn { color: var(--accent); }
.tl-lane.layer { background: transparent; border: 0; border-bottom: 1px dashed var(--line); }
.tl-lane.layer.off { background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(127,127,127,.08) 6px 12px); }
.tl-newlayer { position: absolute; left: 0; right: 0; height: 3px; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); z-index: 4; }
.tl-item.ov.fx { background: linear-gradient(90deg, #7c4dff, #b06bff); color: #fff; }
.tl-item.ov.filter { background: linear-gradient(90deg, #ff9f43, #ff6b9a); color: #fff; }
.tl-item.ov.fx span, .tl-item.ov.filter span { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tl-item.ov.fx svg, .tl-item.ov.filter svg { flex: none; }
.chip.fx { background: #8a5cff; }
.tl-scroll { flex: 1; min-width: 0; overflow: auto; position: relative; }
.tl-content { position: relative; min-height: 100%; }
.tl-ruler { position: absolute; top: 0; cursor: ew-resize; z-index: 3; }
.tl-lanes { position: absolute; inset: 0; }
.tl-lane { position: absolute; left: 0; right: 0; background: var(--tl-lane); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tl-lane.drop { background: var(--accent-soft); outline: 1.5px dashed var(--accent); }
.tl-item { position: absolute; border-radius: 7px; overflow: hidden; cursor: grab; user-select: none; border: 2px solid transparent; }
.tl-item.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); z-index: 2; }
.tl-item.dragging { opacity: .85; z-index: 5; cursor: grabbing; }
.tl-item .h { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 3; }
.tl-item .h.l { left: 0; } .tl-item .h.r { right: 0; }
.tl-item.sel .h { background: rgba(255,255,255,.6); }
.tl-item.sel .h::after { content: ''; position: absolute; top: 35%; bottom: 35%; left: 3px; width: 2px; border-radius: 2px; background: rgba(0,0,0,.45); }
.tl-item.ov { display: flex; align-items: center; padding: 0 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tl-item.ov span { overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tl-item.ov.text { background: var(--c-text); color: #2b1d00; }
.tl-item.ov.image { background: var(--c-oimg); color: #fff; }
.tl-item.vid { background: var(--c-video); }
.tl-item.vid.image { background: var(--c-image); }
.tl-item.vid.missing { background: repeating-linear-gradient(45deg, #b9414f, #b9414f 8px, #8e2e3a 8px, #8e2e3a 16px); }
.tl-item.hidden-clip { opacity: .45; filter: grayscale(.7); }
.tl-item canvas.thumbs { position: absolute; top: 0; pointer-events: none; }
.tl-item .name { position: absolute; left: 6px; top: 4px; font-size: 11px; font-weight: 600; color: #fff; background: rgba(0,0,0,.5); padding: 0 5px; border-radius: 4px; white-space: nowrap; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; pointer-events: none; z-index: 1; }
.tl-item .badge { font-weight: 700; color: #ffd27a; margin-left: 3px; }
.tl-item.aud { background: var(--c-audio); }
.tl-end { position: absolute; width: 2px; background: var(--tl-tick); pointer-events: none; }
.tl-playhead { position: absolute; top: 0; left: 0; width: 0; z-index: 6; pointer-events: none; }
.tl-playhead::before { content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.tl-knob { position: absolute; left: -7px; top: 0; width: 14px; height: 18px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%); pointer-events: auto; cursor: ew-resize; }
.tl-snapline { position: absolute; top: 0; width: 1px; background: #f5b400; z-index: 5; display: none; pointer-events: none; }
.rangebox { display: flex; align-items: center; gap: 5px; background: rgba(255,196,0,.12); border: 1px solid rgba(230,170,0,.5); border-radius: 9px; padding: 2px 4px 2px 9px; }
.rangebox b { font-size: 12px; color: #a87400; font-variant-numeric: tabular-nums; }
[data-theme=dark] .rangebox b { color: #ffe08a; }
.rangebox button { padding: 3px 8px; font-size: 12px; min-height: 0; }
.tl-range { position: absolute; top: 0; background: rgba(255,196,0,.14); border-left: 2px solid #f5b400; border-right: 2px solid #f5b400; pointer-events: none; z-index: 4; }
.tl-range span { position: absolute; top: 4px; left: 4px; font-size: 10px; font-weight: 700; color: #2b1d00; background: #ffd65a; padding: 0 4px; border-radius: 3px; }
.tl-range.mark { width: 0; background: none; border-right: 0; }

/* AI */
.aistatus { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); padding: 8px 10px; background: var(--card2); border-radius: 10px; border: 1px solid var(--line); }
.aistatus .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.aistatus.ok .dot { background: var(--ok); } .aistatus.bad .dot { background: var(--danger); }
.aistatus .msg { flex: 1; }
.ailog { flex: 1; overflow: auto; min-height: 140px; margin: 10px 0; display: flex; flex-direction: column; gap: 10px; }
.ai-hello { background: linear-gradient(160deg, rgba(123,92,255,.12), rgba(176,76,255,.05)); border: 1px solid rgba(123,92,255,.28); border-radius: 12px; padding: 12px; font-size: 13px; }
.ai-hello p { margin: 6px 0 0; color: var(--muted); }
.msg-me { align-self: flex-end; background: var(--accent); color: #fff; padding: 8px 11px; border-radius: 14px 14px 4px 14px; max-width: 90%; font-size: 13px; white-space: pre-wrap; }
.msg-ai { background: var(--card2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 14px 14px 14px 4px; font-size: 13px; }
.msg-ai .plan { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.msg-ai .plan li { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 12px; display: flex; gap: 6px; }
.msg-ai .plan li::before { content: '•'; color: var(--ai); }
.msg-ai .btns { display: flex; gap: 6px; margin-top: 9px; }
.msg-ai .done { color: var(--ok); font-size: 12px; margin-top: 8px; font-weight: 600; }
.msg-ai .err { color: var(--danger); font-size: 12px; margin-top: 6px; }
.msg-ai.thinking { color: var(--ai); }
.chiptoggle { display: none; align-self: flex-start; font-size: 12px; margin-bottom: 6px; }
#aiTab.has-log .chiptoggle { display: block; }
#aiTab.has-log:not(.show-chips) .aichips { display: none; }
.aichips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.aichips button { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(123,92,255,.08); border-color: rgba(123,92,255,.3); color: var(--ai); }
.aiinput textarea { width: 100%; resize: none; }
.airow { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

/* 대화상자 */
.modal { position: fixed; inset: 0; background: rgba(15,20,35,.45); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px); }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 18px; width: min(480px, 94vw); max-height: 90vh; overflow: auto; padding: 20px 22px; box-shadow: 0 30px 80px rgba(10,15,30,.3); }
.sheet.wide { width: min(1000px, 95vw); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.srvopt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--line); }
.srvopt > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.srvopt button { flex: none; }
.sheet-foot a { text-decoration: none; }
.close { background: none; border: 0; }
.newproj { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.newproj input { flex: 1; min-width: 200px; }
.projgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; min-height: 120px; }
.pcard { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: .12s; }
.pcard .pdel { position: absolute; z-index: 2; top: 8px; right: 8px; width: 30px; height: 30px; padding: 0; border-radius: 9px; background: rgba(255,255,255,.92); color: var(--muted); border: 1px solid var(--line2); opacity: 0; transition: opacity .12s; }
.pcard:hover .pdel, .pcard .pdel:focus-visible { opacity: 1; }
.pcard .pdel:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (hover: none) { .pcard .pdel { opacity: 1; } }
button.dangerbtn { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.dangerbtn:hover { filter: brightness(.92); background: var(--danger); }
#delCloudRow { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; }
#delCloudRow[hidden] { display: none; }
.pcard:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,40,90,.1); }
.pcard .thumb { aspect-ratio: 16/9; background: #1a1d25 center/cover no-repeat; display: grid; place-items: center; color: #6b7385; }
.pcard .meta { padding: 9px 11px; }
.pcard .meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .meta span { font-size: 12px; color: var(--muted); }
.pcard .ext { font-size: 10px; color: var(--warn); }
.empty { color: var(--muted); grid-column: 1/-1; text-align: center; padding: 30px; }
.projfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.form input, .form select { color: var(--text); }
.progress { margin-top: 14px; }
.progress .bar { height: 10px; background: var(--card3); border-radius: 99px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--ai)); transition: width .3s; }
.progress .stage-txt { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ctxmenu { position: fixed; z-index: 80; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 5px; min-width: 220px; box-shadow: 0 16px 40px rgba(10,20,40,.22); }
.ctxmenu button { display: flex; width: 100%; justify-content: space-between; gap: 18px; background: none; border: 0; border-radius: 8px; padding: 7px 10px; text-align: left; font-size: 13px; }
.ctxmenu button:hover { background: var(--accent); color: #fff; }
.ctxmenu button kbd { background: none; border: 0; color: var(--dim); font-size: 11px; }
.ctxmenu button:hover kbd { color: #dfe8ff; }
.ctxmenu button.danger { color: var(--danger); }
.ctxmenu button.danger:hover { color: #fff; background: var(--danger); }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys th { text-align: left; color: var(--accent); padding: 12px 0 4px; font-size: 12px; }
.keys td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.keys td:first-child { width: 160px; white-space: nowrap; }
.time.tc { cursor: text; border-radius: 6px; padding: 1px 4px; }
.time.tc:hover { background: var(--card3); }
.tcinput { width: 86px; padding: 2px 6px; font-variant-numeric: tabular-nums; }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: #1d2230; color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: 80vw; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13.5px; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #b3262c; }

@media (max-width: 1250px) { .workspace { grid-template-columns: 60px 250px minmax(0, 1fr) 260px; } .projname { width: 170px; } .topbar button.soft { font-size: 12px; padding: 6px 8px; } }
@media (max-width: 980px) { .workspace { grid-template-columns: 56px 220px minmax(0, 1fr) 220px; } .savestate, .reslabel { display: none; } .projname { width: 120px; } .topbar button.soft .ic { display: none; } }

/* 꾸미기 패널 */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 14px 0 8px; font-size: 13px; }
.sec-head:first-child { margin-top: 2px; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tgrid .tpreset { height: 76px; }
.tpreset canvas { width: 100%; height: 100%; display: block; }
.sgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.stk { font-size: 24px; padding: 4px 0; background: var(--card2); border-color: transparent; border-radius: 10px; font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; }
.stk:hover { background: var(--accent-soft); transform: scale(1.12); }
.recbox { display: flex; align-items: center; gap: 8px; }
.rec { background: #fff0f0; border-color: #ffc9c9; color: #d62b2b; font-weight: 700; }
[data-theme=dark] .rec { background: rgba(229,72,77,.15); border-color: rgba(229,72,77,.4); }
.rec.on { background: #e5484d; color: #fff; border-color: #e5484d; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(229,72,77,.18); } }
.meter { flex: 1; height: 8px; background: var(--card3); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #17a673, #f5b400, #e5484d); transition: width .06s; }
label.check { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; color: var(--muted); }
.sfxlist { display: grid; gap: 2px; }
.sfxgroup { font-size: 11.5px; color: var(--dim); font-weight: 700; margin: 8px 0 2px; }
.sfx { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 8px; font-size: 13px; }
.sfx:hover { background: var(--card2); }
.sfx span:first-of-type { flex: 1; }
.sfx button { min-width: 28px; min-height: 28px; padding: 4px; }
.fxgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.fxgrid.two { grid-template-columns: 1fr 1fr; }
.fxtile { flex-direction: column; gap: 5px; padding: 6px 4px 7px; border-color: var(--line); font-size: 11.5px; font-weight: 600; color: var(--text); white-space: normal; line-height: 1.2; }
.fxtile:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fxprev { width: 100%; aspect-ratio: 16/9; border-radius: 6px; background: #2a3550; overflow: hidden; display: grid; place-items: center; color: #fff; }
.fxprev i { display: block; width: 100%; height: 100%; background: linear-gradient(135deg, #5b8cff 0 33%, #ffb84d 33% 66%, #3fc69a 66%); }
.fxprev.mos { background: repeating-conic-gradient(#8a96b5 0 25%, #5f6c8f 0 50%) 0 0/12px 12px; }
.fxprev.blurbox { background: radial-gradient(circle at 40% 40%, #ffd28a, #5b8cff); filter: blur(3px); }
.fxprev canvas { width: 100%; height: 100%; display: block; }
.trprev { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: #000; }
.trprev i { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 15px; color: #fff; }
.trprev .a { background: #4d7cff; z-index: 1; } .trprev .b { background: #ff9f43; opacity: 0; z-index: 2; }
.fltprev { width: 100%; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: linear-gradient(135deg, #4d7cff, #ffb84d 50%, #3fc69a); }
.fltprev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fltprev img:not([src]) { display: none; }
.target-hint { min-height: 16px; }
.subprev { border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.subprev canvas { width: 100%; display: block; }
.tl-item.ov.mosaic { background: repeating-conic-gradient(#8a96b5 0 25%, #6c7898 0 50%) 0 0/10px 10px; color: #fff; text-shadow: 0 1px 2px #000; }
.tl-item.ov.decor { background: #2f9e8f; color: #fff; }
.tl-item.ov.sticker { background: #ff8fb1; color: #3a0016; font-size: 15px; font-family: 'Segoe UI Emoji', sans-serif; }
.tl-trans { position: absolute; height: 22px; margin-top: -11px; background: rgba(255,255,255,.92); border: 2px solid var(--accent); border-radius: 6px; z-index: 4; display: grid; place-items: center; color: var(--accent); font-size: 12px; font-weight: 800; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.25); min-width: 16px; }
.tl-trans:hover { background: var(--accent); color: #fff; }
.tl-joint { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 5px; background: #fff; border: 1.5px solid var(--line2); z-index: 4; display: grid; place-items: center; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .12s; }
.tl-lanes:hover .tl-joint { opacity: .9; }
.tl-joint:hover { opacity: 1 !important; border-color: var(--accent); color: var(--accent); }
.tl-item .fxbadge { margin-left: 3px; }
.adj { display: grid; grid-template-columns: 44px 1fr 30px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.adj b { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.props select { width: 100%; }
.pcard.newcard { border: 2px dashed var(--line2); background: var(--card2); }
.pcard.newcard .thumb { background: transparent; }
.pcard.newcard .plus { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(47,107,255,.35); }
.pcard.newcard:hover { border-color: var(--accent); }
button.soft.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.ratios { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 6px; }
.ratios button { flex-direction: column; gap: 4px; padding: 10px 6px; height: 128px; justify-content: flex-end; border-color: var(--line); }
.ratios button i { display: block; height: 52px; max-width: 80%; background: var(--card3); border: 2px solid var(--line2); border-radius: 5px; margin-bottom: auto; margin-top: 4px; }
.ratios button b { font-size: 13px; } .ratios button span { font-size: 11px; color: var(--muted); }
.ratios button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ratios button.on i { border-color: var(--accent); background: var(--accent-soft); }
.tl-marquee { position: absolute; border: 1.5px dashed var(--accent); background: var(--accent-soft); z-index: 7; pointer-events: none; border-radius: 4px; }
#fltMode, #fxMode { flex-wrap: wrap; } #fltMode button, #fxMode button { flex: 1 1 auto; white-space: nowrap; }

/* 계정·클라우드 */
.account { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 3px 12px 3px 3px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; max-width: 170px; }
.account:hover { border-color: var(--accent); }
.account .av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; overflow: hidden; flex: none; }
.account .av img { width: 100%; height: 100%; object-fit: cover; }
.account .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account.on { padding-right: 10px; }
.popmenu { position: fixed; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 40px rgba(20,30,60,.18); padding: 8px; min-width: 240px; }
.popmenu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.popmenu .who b { display: block; font-size: 14px; } .popmenu .who span { font-size: 12px; color: var(--muted); }
.popmenu button { all: unset; display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 9px; font-size: 13px; cursor: pointer; color: var(--text); }
.popmenu button:hover { background: var(--accent-soft); color: var(--accent); }
.popmenu .note { font-size: 11.5px; color: var(--muted); padding: 6px 10px; line-height: 1.5; }
.sec-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.cloudsec { margin-bottom: 16px; }
.cloudsec:empty { display: none; }
.cloudsec .cloudbar { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 10px; }
.cloudsec .cloudbar .grow { flex: 1; }
.cloudlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.ccard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); cursor: pointer; display: flex; flex-direction: column; gap: 3px; position: relative; }
.ccard:hover { border-color: var(--accent); }
.ccard b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 22px; }
.ccard span { font-size: 12px; color: var(--muted); }
.ccard .here { color: var(--accent); font-weight: 700; }
.ccard .del { position: absolute; top: 6px; right: 6px; all: unset; position: absolute; top: 7px; right: 8px; cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.ccard .del:hover { color: var(--danger, #e5484d); background: var(--card3); }
.conn-body { font-size: 14px; line-height: 1.6; max-width: 520px; }
.conn-body .steps { padding-left: 20px; } .conn-body .steps li { margin: 6px 0; }

#aiProv { margin-bottom: 8px; }
.aiwho { display: flex; align-items: center; gap: 8px; margin: 6px 2px 2px; line-height: 1.45; }
.aiwho span { flex: 1; } .aiwho button { flex: none; }

/* 위쪽 연결 상태 표시 */
.connbadge { padding: 4px 10px 4px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; gap: 6px; border: 1px solid var(--line2); background: var(--card); color: var(--muted); }
.connbadge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.connbadge.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.connbadge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line2)); }
.connbadge.old .dot { background: var(--warn); } .connbadge.old { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line2)); }
.connbadge.off .dot, .connbadge.none .dot { background: var(--danger); animation: connblink 1.2s ease-in-out infinite; }
.connbadge.off, .connbadge.none { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line2)); }
.connbadge.none { background: var(--danger); color: #fff; } .connbadge.none .dot { background: #fff; }
@keyframes connblink { 50% { opacity: .35; } }
a.btnlink { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line2); text-decoration: none; color: inherit; white-space: nowrap; }
a.btnlink.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
a.btnlink.primary:hover { background: var(--accent-h); }
a.btnlink[hidden] { display: none; }

/* 연결 프로그램 새 버전 알림 */
#updBar { position: fixed; z-index: 900; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px 10px 14px; background: var(--card); color: var(--text); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 13px; line-height: 1.45; }
#updBar > span:first-child { flex: 1; min-width: 240px; }
#updBar .ub-act { display: flex; gap: 6px; align-items: center; }
#updBar a.btn { text-decoration: none; display: inline-flex; align-items: center; padding: 5px 10px; font-size: 13px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap; }
#updBar a.btn:hover { background: var(--accent-h); }

/* 설치 진행 막대 */
.setupprog { margin: 8px 0 2px; font-size: 12.5px; line-height: 1.5; }
.setupprog .sp-t { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.setupprog.ok .sp-t { color: var(--ok); } .setupprog.bad .sp-t { color: var(--danger); font-weight: 500; }
.sp-bar { position: relative; height: 7px; background: var(--card3); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.sp-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 99px; transition: width .5s; }
.sp-bar.ind i { animation: spind 1.3s ease-in-out infinite; }
@keyframes spind { 0% { left: -35%; } 100% { left: 100%; } }
#ffProg { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); }

/* AI 처음 연결하기 카드 */
.aisetup { margin: 8px 0 4px; padding: 10px 12px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--card2); font-size: 12.5px; }
.aisetup .as-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.as-steps { list-style: none; margin: 0; padding: 0; }
.as-steps li { display: flex; gap: 9px; padding: 7px 0; border-top: 1px dashed var(--line); line-height: 1.45; }
.as-steps li:first-child { border-top: 0; }
.as-steps .no { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--card3); color: var(--muted); }
.as-steps li > div { flex: 1; min-width: 0; }
.as-steps li.ok .no { background: var(--ok); color: #fff; } .as-steps li.ok b { color: var(--muted); font-weight: 600; }
.as-steps li.cur .no { background: var(--accent); color: #fff; }
.as-steps li.wait { opacity: .6; }
.as-steps li button { margin-top: 6px; }
.as-steps li.cur button.primary { width: 100%; padding: 8px; }

/* 미리보기 카드(크게·그림 장면) */
.tgrid { grid-template-columns: 1fr 1fr; gap: 8px; }
.tgrid .tpreset { height: auto; aspect-ratio: 16/10; background: #1d2029; }
.tpreset span.lbl { left: 0; right: 0; top: auto; bottom: 0; padding: 14px 8px 5px; font-size: 11.5px; font-weight: 600; color: #e9ecf3; background: linear-gradient(transparent, rgba(0,0,0,.55)); text-align: left; }
.fxgrid.big { gap: 10px; }
.fxgrid.big .fxtile { padding: 5px 5px 8px; font-size: 12.5px; }
.fxprev.scene, .fltprev { aspect-ratio: 16/9; background: #1d2029; overflow: hidden; }
.fxprev.scene canvas, .fltprev canvas { width: 100%; height: 100%; display: block; transform-origin: 50% 50%; }
.trprev canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.trprev .flash { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; }
.wgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.wvt { display: flex; flex-direction: column; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: grab; font-size: 11.5px; font-weight: 600; color: var(--text); }
.wvt canvas { width: 100%; aspect-ratio: 16/9; border-radius: 8px; background: #12141b; display: block; }
.wvt:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-item.ov.wave { background: linear-gradient(90deg, #1e6bff, #b45bff); color: #fff; }

.animrow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 4px 0 6px; }
.animrow label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.animrow select { min-width: 0; width: 100%; font-size: 12px; }

/* 미니PC 작업대 모드: 이 PC 전용 기능은 숨기고, 작업대 전용 기능만 보이기 */
.srvonly { display: none !important; }
body.srvmode .srvonly { display: inline-flex !important; }
body.srvmode span.srvonly { display: inline !important; }
body.srvmode .pconly, body.srvmode #whInstall { display: none !important; }
.pcard .exp { position: absolute; left: 8px; top: 8px; z-index: 2; font-size: 11.5px; padding: 3px 8px; border-radius: 99px; background: rgba(0,0,0,.62); color: #fff; }
.finlist { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; align-items: center; }
.urow { display: flex; align-items: center; gap: 8px; justify-content: space-between; width: 100%; padding: 6px 2px; border-bottom: 1px dashed var(--line); font-size: 13px; }
#accountMenu .sub { font-size: 12px; color: var(--muted); padding: 8px 12px 2px; }
#accountMenu .segrow { display: flex; gap: 4px; padding: 4px 10px 8px; }
#accountMenu .segrow button { flex: 1; justify-content: center; padding: 5px 0; font-size: 12.5px; border: 1px solid var(--line2); border-radius: 8px; }
#accountMenu .segrow button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
