/* ============================================================
   Editor — 2x2 grid (stage / props 上半，timeline / textPanel 下半)
   每一個 splitter 都可拖
============================================================ */
.app {
  display: grid;
  grid-template-columns: 1fr 5px var(--props-w, 320px);
  grid-template-rows: 40px 1fr 5px var(--tl-h, 320px);
  grid-template-areas:
    "top      top    top"
    "stage    sp1    props"
    "sp2      sp2    sp2"
    "tl       sp3    text";
  height: 100vh;
}
.app.hidden { display: none; }

/* 頂列 */
.top {
  grid-area: top;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.brand b { color: var(--accent); }
.brand .tag { font-size: 10px; color: var(--text-2); margin-left: 6px; font-weight: 400; }
.top-btn { padding: 5px 10px; border-radius: 3px; color: var(--text-1); font-size: 12px; }
.top-btn:hover { background: var(--bg-3); color: var(--text-0); }
.top-btn.primary { background: var(--accent); color: var(--accent-deep); font-weight: 600; }
.top-btn.primary:hover { background: var(--accent-hover); }
.top-spacer { flex: 1; }
.top-stat { font-family: var(--mono); font-size: 10px; color: var(--text-2); display: flex; gap: 12px; }
.top-stat b { color: var(--text-1); font-weight: 400; }
.undo-group { display: flex; gap: 2px; }
.undo-group button { padding: 5px 8px; border-radius: 3px; color: var(--text-2); }
.undo-group button:hover:not(:disabled) { background: var(--bg-3); color: var(--text-0); }
.undo-group button:disabled { opacity: 0.3; cursor: not-allowed; }
.add-btns { display: flex; gap: 2px; }
.add-btns.inline { padding-left: 4px; border-left: 1px solid var(--line); margin-left: 2px; padding-right: 2px; }
.add-btns .icon-btn { padding: 5px 7px; border-radius: 3px; color: var(--text-2); }
.add-btns .icon-btn:hover { background: var(--bg-3); color: var(--accent); }

/* Splitter */
.splitter {
  background: var(--bg-0);
  position: relative; z-index: 5;
  transition: background 0.12s;
}
.splitter:hover, .splitter.dragging { background: var(--accent); }
.splitter::after {
  content: ''; position: absolute;
  background: var(--text-2); opacity: 0.3; border-radius: 1px;
}
.splitter-v { cursor: col-resize; }
.splitter-h { cursor: row-resize; }
.splitter-v::after { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 1px; height: 24px; }
.splitter-h::after { top: 50%; left: 50%; transform: translate(-50%, -50%); height: 1px; width: 24px; }
#splitStageProps { grid-area: sp1; }
#splitMid { grid-area: sp2; }
#splitTlText { grid-area: sp3; }

/* 舞台 */
.stage-area {
  grid-area: stage;
  background:
    repeating-conic-gradient(#0d0e11 0% 25%, #0a0b0e 0% 50%) 0 0 / 24px 24px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.stage-area.drag-over {
  background:
    repeating-conic-gradient(rgba(34, 211, 184, 0.12) 0% 25%, rgba(34, 211, 184, 0.05) 0% 50%) 0 0 / 24px 24px;
}
.stage-area.drag-over::after {
  content: '放開以匯入素材';
  position: absolute; inset: 20px;
  border: 2px dashed var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 16px; font-weight: 600;
  pointer-events: none;
}
.stage-wrap {
  position: relative;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 0 1px var(--line);
}
#stage { display: block; background: #000; }
.stage-meta {
  position: absolute; bottom: 12px; left: 12px;
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  background: rgba(10,11,14,0.8); padding: 4px 8px; border-radius: 3px;
  backdrop-filter: blur(8px);
}

/* 舞台框選矩形 */
.marquee {
  position: absolute; pointer-events: none;
  border: 1px dashed var(--accent);
  background: rgba(34,211,184,0.08);
  z-index: 7;
}

/* 選取框 + handles */
.sel-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}
.sel-box {
  position: absolute;
  border: 1.5px dashed var(--accent);
  box-sizing: border-box;
  pointer-events: none;
}
.sel-h {
  position: absolute;
  width: 9px; height: 9px;
  background: var(--bg-0);
  border: 1.5px solid var(--accent);
  border-radius: 1px;
  pointer-events: auto;
  z-index: 6;
}
.sel-h.n  { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.sel-h.s  { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.sel-h.e  { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.sel-h.w  { left: -5px;  top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.sel-h.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.sel-h.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.sel-h.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.sel-h.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* 屬性面板（右上） */
.props-panel {
  grid-area: props;
  background: var(--bg-1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}
.props-body { flex: 1; overflow-y: auto; min-height: 0; }
.fx-body { max-height: 35%; }
.panel-head {
  height: 30px; padding: 0 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-2);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  justify-content: space-between;
}
.sec { border-bottom: 1px solid var(--line); padding: 6px 0 10px; }
.sec-h {
  padding: 8px 12px 6px;
  font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between;
}
.row { padding: 3px 12px; display: flex; align-items: center; gap: 6px; min-height: 24px; }
.lbl { width: 60px; font-size: 11px; color: var(--text-1); flex-shrink: 0; }
input.f, select.f {
  flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 3px; padding: 3px 7px; color: var(--text-0);
  font-size: 11px; font-family: var(--mono);
}
input.f:focus, select.f:focus { outline: none; border-color: var(--accent); }
select.f { cursor: pointer; }
input[type="color"].f { padding: 1px; height: 22px; cursor: pointer; }

/* 文字面板（右下） */
.text-panel {
  grid-area: text;
  background: var(--bg-1); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}

.empty {
  padding: 28px 16px; text-align: center;
  color: var(--text-2); font-size: 11px; line-height: 1.7;
}
.empty b { color: var(--text-1); display: block; margin-bottom: 6px; font-size: 12px; }
.empty kbd { font-family: var(--mono); background: var(--bg-3); padding: 1px 5px; border-radius: 2px; font-size: 10px; color: var(--accent-2); }

/* 按鈕組（faux bold / italic / 對齊） */
.btn-row { display: flex; gap: 3px; padding: 4px 12px; }
.btn-row button {
  flex: 1; padding: 4px 0;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text-1); border-radius: 3px;
  font-size: 11px; font-family: var(--mono);
  cursor: pointer;
}
.btn-row button:hover { background: var(--bg-3); color: var(--text-0); }
.btn-row button.on {
  background: rgba(34,211,184,0.18); border-color: var(--accent); color: var(--accent);
}
