/* LOVART-PLUS ∞ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #101014; --bg2: #17171d; --bg3: #1f1f27; --line: #2b2b36;
  --fg: #e8e8ee; --dim: #9a9aa8; --acc: #7c5cff; --acc2: #ff5c8a; --ok: #37d67a;
}
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--fg);
  font: 13px/1.5 -apple-system, "PingFang TC", "Noto Sans TC", sans-serif;
  display: grid;
  grid-template: "top top top" 46px "tools canvas panel" 1fr / 52px 1fr 360px;
}

/* topbar */
#topbar { grid-area: top; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: 1px; background: linear-gradient(90deg, var(--acc), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand span { font-weight: 400; }
#projName { background: transparent; border: 1px solid transparent; color: var(--fg); padding: 4px 8px; border-radius: 6px; width: 200px; }
#projName:focus { border-color: var(--line); outline: none; background: var(--bg3); }
.grow { flex: 1; }

.btn { background: var(--acc); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { filter: brightness(1.15); }
.btn.ghost { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* toolbar */
#toolbar { grid-area: tools; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 6px; }
.tool { width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--dim); font-size: 16px; cursor: pointer; }
.tool:hover { background: var(--bg3); color: var(--fg); }
.tool.active { background: var(--acc); color: #fff; }
.sep { width: 24px; height: 1px; background: var(--line); margin: 6px 0; }

/* canvas */
#viewport { grid-area: canvas; position: relative; overflow: hidden; cursor: default;
  background: radial-gradient(circle at 1px 1px, #23232d 1px, transparent 0) 0 0/24px 24px, var(--bg); }
#viewport.hand { cursor: grab; }
#viewport.hand.panning { cursor: grabbing; }
#world { position: absolute; transform-origin: 0 0; }
#zoomBadge { position: absolute; right: 12px; bottom: 12px; background: var(--bg3); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; color: var(--dim); font-size: 12px; pointer-events: none; }
#marquee { position: absolute; border: 1px solid var(--acc); background: rgba(124,92,255,.12); pointer-events: none; }

.obj { position: absolute; user-select: none; }
.obj img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }
.obj.frame { border: 1.5px solid #4a4a5e; background: rgba(255,255,255,.02); }
.obj.frame .frameLabel { position: absolute; top: -22px; left: 0; color: var(--dim); font-size: 12px; white-space: nowrap; }
.obj.text { white-space: pre-wrap; overflow: hidden; }
.obj.selected { outline: 1.5px solid var(--acc); }
.handle { position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--acc); border-radius: 2px; z-index: 10; }
.handle.nw { cursor: nwse-resize; } .handle.se { cursor: nwse-resize; }
.handle.ne { cursor: nesw-resize; } .handle.sw { cursor: nesw-resize; }

/* right panel */
#panel { grid-area: panel; background: var(--bg2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: transparent; border: 0; color: var(--dim); padding: 10px 4px; cursor: pointer; font-size: 12px; }
.tab.active { color: var(--fg); box-shadow: inset 0 -2px 0 var(--acc); }
.tabpage { display: none; flex-direction: column; flex: 1; min-height: 0; padding: 10px; gap: 8px; overflow-y: auto; }
.tabpage.active { display: flex; }

/* agent chat */
#tab-agent { padding: 0; }
#chatLog { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--acc); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--bg3); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; color: var(--dim); font-size: 12px; background: transparent; }
.msg img.genthumb { max-width: 140px; border-radius: 8px; margin: 4px 4px 0 0; }
#chatQuick { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.chip { background: var(--bg3); border: 1px solid var(--line); color: var(--dim); border-radius: 999px; padding: 4px 10px; font-size: 11px; cursor: pointer; }
.chip:hover { color: var(--fg); border-color: var(--acc); }
#chatInputRow { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
#chatInput { flex: 1; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; color: var(--fg); padding: 8px; resize: none; font: inherit; }
#chatInput:focus { outline: none; border-color: var(--acc); }

/* video */
.vrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vrow label { display: flex; flex-direction: column; gap: 3px; color: var(--dim); font-size: 12px; }
select, dialog input { background: var(--bg3); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 8px; font: inherit; }
#sceneList { display: flex; flex-direction: column; gap: 6px; min-height: 60px; }
.scene { display: flex; gap: 8px; align-items: center; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.scene .thumb { width: 64px; height: 36px; border-radius: 4px; object-fit: cover; background: #000; flex: none; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--dim); overflow: hidden; }
.scene .thumb img { width: 100%; height: 100%; object-fit: cover; }
.scene .meta { flex: 1; min-width: 0; font-size: 12px; }
.scene .meta .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene input.dur { width: 52px; background: var(--bg2); border: 1px solid var(--line); color: var(--fg); border-radius: 4px; padding: 2px 4px; }
.scene .ops button { background: transparent; border: 0; color: var(--dim); cursor: pointer; font-size: 13px; }
.scene .ops button:hover { color: var(--fg); }
#vidTotal { color: var(--ok); font-weight: 600; }
#renderStatus { font-size: 12px; color: var(--dim); }
#renderStatus .bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; margin-top: 4px; }
#renderStatus .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); transition: width .3s; }
#renderList a { color: var(--acc); text-decoration: none; display: block; padding: 4px 0; font-size: 12px; word-break: break-all; }
#tab-video h4 { color: var(--dim); font-weight: 600; margin-top: 6px; }

/* tts */
#ttsBox { border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
#ttsBox summary { cursor: pointer; color: var(--dim); font-size: 12px; }
#ttsBox textarea { width: 100%; margin: 8px 0; background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; color: var(--fg); padding: 6px; font: inherit; resize: vertical; }
#ttsBox input { background: var(--bg3); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 4px 6px; }

/* assets */
#assetGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.assetCard { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--bg3); }
.assetCard img, .assetCard video { width: 100%; height: 72px; object-fit: cover; display: block; }
.assetCard .aname { font-size: 10px; color: var(--dim); padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assetCard .del { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.6); border: 0; color: #fff; border-radius: 4px; cursor: pointer; font-size: 10px; padding: 1px 5px; display: none; }
.assetCard:hover .del { display: block; }
.assetCard .audioIcon { height: 72px; display: flex; align-items: center; justify-content: center; font-size: 24px; }

/* layers */
.layerRow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.layerRow:hover { background: var(--bg3); }
.layerRow.selected { background: var(--bg3); box-shadow: inset 2px 0 0 var(--acc); }
.layerRow .lt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.layerRow .lk { color: var(--dim); font-size: 11px; }

/* dialog */
dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 420px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin-bottom: 14px; font-size: 15px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; color: var(--dim); font-size: 12px; }
dialog input { width: 100%; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
