:root {
  color-scheme: dark;
  --bg: #10131a;
  --panel: #191d27;
  --panel2: #232838;
  --line: rgba(255,255,255,.12);
  --text: #fff7ed;
  --muted: #b9b0a8;
  --accent: #f3b777;
  --accent2: #8fc7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 75% 0%, rgba(247, 158, 91, .18), transparent 34%), var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

header {
  height: 74px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 19, 26, .92);
}

h1 { margin: 0; font-size: 20px; }
p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
button, input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }

main {
  display: grid;
  grid-template-columns: 260px 1fr 360px;
  gap: 14px;
  height: calc(100vh - 74px);
  padding: 14px;
}

aside, .stage-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(25, 29, 39, .88);
}

.scene-list, .inspector { padding: 14px; }
.panel-title { color: var(--accent); font-weight: 700; margin: 8px 0 10px; }
.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding-bottom: 10px;
  background: rgba(25, 29, 39, .96);
}
.tab {
  padding: 8px 0;
  border-radius: 12px;
  font-size: 14px;
  color: var(--muted);
}
.tab.active {
  color: #1a120c;
  background: linear-gradient(180deg, #ffd6a1, var(--accent));
  border-color: transparent;
  font-weight: 700;
}
.edit-panel {
  display: none;
  min-height: 320px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025));
}
.edit-panel.active { display: block; }

.scene-item {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.scene-item.active { border-color: var(--accent); background: rgba(243, 183, 119, .12); }
.scene-item small { display: block; color: var(--muted); }

.stage-wrap { padding: 14px; }
.stage-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: 16px;
  background: #000;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}

#bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.actor {
  position: absolute;
  transform: translate(-50%, -100%);
  transform-origin: bottom center;
  touch-action: none;
  cursor: grab;
  filter: drop-shadow(0 18px 20px rgba(0,0,0,.35));
}
.actor.selected { outline: 2px solid var(--accent2); }

.dialogue-box {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 4%;
  min-height: 110px;
  padding: 18px 24px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(20,24,34,.78), rgba(10,12,18,.88));
  backdrop-filter: blur(8px);
}
#speakerName { color: var(--accent); font-weight: 700; margin-bottom: 7px; }
#previewText { font-size: 22px; line-height: 1.45; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

label { display: block; margin-bottom: 10px; color: var(--muted); }
label input, label select, label textarea { width: 100%; margin-top: 5px; }
textarea { min-height: 70px; resize: vertical; }

.row {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.row-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.tiny {
  font-size: 12px;
  color: var(--muted);
}
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.line-text { min-height: 64px; }
#musicPlayer { width: 100%; margin: 8px 0 12px; }
#assetPreview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.asset-chip {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  font-size: 12px;
  word-break: break-all;
}
.asset-chip img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 6px;
}

@media (max-width: 980px) {
  header { height: auto; align-items: flex-start; gap: 10px; flex-direction: column; }
  main { grid-template-columns: 1fr; height: auto; }
  .scene-list, .inspector { max-height: none; }
}
