:root {
  --bg: #14161a;
  --panel: #1c1f25;
  --panel-2: #23272e;
  --panel-3: #2a2f38;
  --line: #2c313a;
  --text: #e6e8ec;
  --muted: #98a0ad;
  --accent: #4c8dff;
  --danger: #e5534b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: 48px 1fr;
}

/* ---------------------------------------------------------------- 顶栏 */

#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex: 0 0 auto;
}

.brand-mark {
  color: var(--accent);
  font-size: 15px;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-sub {
  color: var(--muted);
  font-size: 11px;
}

.seg {
  display: flex;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px;
  flex: 0 0 auto;
}

.seg .btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 12px;
}

.seg .btn.on {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 11.5px;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn:hover {
  background: #333a45;
  border-color: #3d4552;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover {
  background: #5f9bff;
}

.btn.danger {
  color: #ff8b84;
  border-color: #40292a;
  background: #2a1f21;
  width: 100%;
  margin-top: 12px;
}

.btn.danger:hover {
  background: #3a2628;
}

.btn.mini {
  padding: 2px 8px;
  font-size: 11px;
}

.btn.ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
  font-size: 15px;
  line-height: 1;
}

.btn.ghost:hover {
  color: #ff8b84;
  background: transparent;
}

/* ---------------------------------------------------------------- 布局 */

#layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 288px;
  min-height: 0;
}

#left,
#right {
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
}

#left {
  border-right: 1px solid var(--line);
}

#right {
  border-left: 1px solid var(--line);
}

#left::-webkit-scrollbar,
#right::-webkit-scrollbar {
  width: 8px;
}

#left::-webkit-scrollbar-thumb,
#right::-webkit-scrollbar-thumb {
  background: #333a45;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- 视口 */

#viewport {
  position: relative;
  overflow: hidden;
  background: #0d0f12;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

#canvas-host {
  position: relative;
  width: 100%;
  height: 100%;
}

#canvas-host canvas {
  display: block;
}

#viewport.shot-mode #canvas-host {
  box-shadow: 0 0 0 9999px #05070a;
  border-radius: 2px;
}

#hud {
  position: absolute;
  left: 12px;
  bottom: 10px;
  color: #9aa3b0;
  font-size: 11px;
  background: rgba(10, 12, 16, 0.55);
  padding: 4px 9px;
  border-radius: 5px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

/* ---------------------------------------------------------------- 左栏 */

section + section {
  margin-top: 18px;
}

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid transparent;
  cursor: pointer;
}

.row:hover {
  background: #272c34;
}

.row.on {
  border-color: var(--accent);
  background: #222b3b;
}

.row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.row-title {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  color: var(--accent);
  font-size: 10px;
}

.empty,
.panel-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 10px 2px;
}

.panel-empty-title {
  color: var(--text);
  margin-bottom: 4px;
}

/* ---------------------------------------------------------------- 右栏 */

.panel-title {
  font-size: 11.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 4px;
}

.text,
.select {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  outline: none;
}

.text:focus,
.select:focus {
  border-color: var(--accent);
}

.color {
  width: 100%;
  height: 30px;
  padding: 2px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.slider {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider input[type="range"] {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: #3a4150;
  outline: none;
}

.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #1b1e24;
}

.slider-val {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
}

.kv code {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}

/* ---------------------------------------------------------------- Toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 12px);
  background: #2b3341;
  color: #eaf0ff;
  border: 1px solid #3c4759;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 999;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- 登录 */

#login {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.9);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px 22px 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.login-sub {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 18px;
  line-height: 1.6;
}

.login-input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  outline: none;
}

.login-input:focus {
  border-color: var(--accent);
}

.login-btn {
  width: 100%;
  margin-top: 12px;
  padding: 9px;
}

.login-err {
  color: #ff8b84;
  font-size: 12px;
  min-height: 18px;
  margin-top: 8px;
}

/* ---------------------------------------------------------------- 无限画布 */

#layout.board-mode {
  grid-template-columns: 232px minmax(0, 1fr) 0;
}

#layout.board-mode #right {
  padding: 0;
  border: 0;
  overflow: hidden;
}

#board {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #101216;
  background-image: radial-gradient(circle at 1px 1px, #23262d 1px, transparent 0);
  background-size: 24px 24px;
}

/* hidden 属性会被下面的 display:flex 覆盖，必须显式声明 */
#board[hidden],
#board-tools[hidden] {
  display: none !important;
}

.board {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.board.panning {
  cursor: grabbing;
}

.board-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.board-edges {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}

.board-nodes {
  position: absolute;
  left: 0;
  top: 0;
}

.edge-line {
  fill: none;
  stroke: #3d4a63;
  stroke-width: 2;
}

.edge-line.on {
  stroke: var(--accent);
  stroke-width: 2.5;
}

.edge-temp {
  stroke: var(--accent);
  stroke-dasharray: 5 4;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
  cursor: pointer;
}

.node {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  /* 必须是 visible：端口圆点有一半在节点外面，hidden 会把它们裁掉 */
  overflow: visible;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.node.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.node.dragging {
  opacity: 0.92;
}

.node-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  border-radius: 9px 9px 0 0;
  font-size: 12px;
  cursor: grab;
}

.node-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.node-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  border-radius: 0 0 9px 9px;
  overflow: hidden;
}

.node-text {
  flex: 1 1 auto;
  width: 100%;
  resize: none;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
  user-select: text;
}

.node-ph {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
}

.node-action {
  width: 100%;
}

.node-hint {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
  text-align: center;
}

.port {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #1b1e24;
  border: 2px solid #4a5468;
}

.port-in {
  left: -6px;
}

.port-out {
  right: -6px;
  cursor: crosshair;
}

.port-out:hover {
  border-color: var(--accent);
  background: var(--accent);
}

#board-tools {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 7px 9px;
  background: rgba(24, 27, 33, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 5;
}

.btn.chip {
  padding: 4px 10px;
  font-size: 11.5px;
}

.chip-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--line);
}

/* ---------------------------------------------------------------- 框选 */

.marquee {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--accent);
  background: rgba(76, 141, 255, 0.12);
  border-radius: 3px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- 资产库 */

.asset-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 5px;
}

.asset-group-label {
  font-size: 11.5px;
  letter-spacing: 0.3px;
}

.asset-row {
  border-left: 3px solid transparent;
}

/* ---------------------------------------------------------------- 节点状态 */

.node-dot.dot-dirty {
  background: #e0b25f;
}

.node-dot.dot-done {
  background: #5fc28a;
}

.node-dot.dot-error {
  background: #e5534b;
}

.node-dot.dot-running {
  background: var(--accent);
}

.node.st-dirty {
  border-color: #4a3f24;
}

.node.st-error {
  border-color: #4a2a29;
}

.node-err {
  margin-top: 6px;
  color: #ff8b84;
  font-size: 11px;
  text-align: center;
}

.asset-tag {
  display: inline-block;
  align-self: flex-start;
  margin-bottom: 8px;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 10.5px;
}

.asset-name {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
}

.asset-note {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.node-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0 0 9px 9px;
  user-select: none;
  -webkit-user-drag: none;
}

.node-audio {
  width: 100%;
  height: 34px;
  margin-top: 2px;
}

.node-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0 0 9px 9px;
  background: #000;
}

.asset-portrait {
  height: 96px;
  margin-bottom: 8px;
  border-radius: 6px;
}

.proj-select {
  max-width: 180px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  outline: none;
}

.mini-select {
  max-width: 116px;
  font: inherit;
  font-size: 11px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 4px;
  outline: none;
}

.shot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}

.shot-grid .btn {
  padding: 4px 2px;
  font-size: 11px;
}

.text-action {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.text-action .text {
  flex: 1 1 auto;
  min-width: 0;
}

.joints {
  margin: 6px 0 12px;
}

.joints summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11.5px;
  padding: 4px 0;
  outline: none;
}

.joints[open] summary {
  color: var(--text);
}

.joints .field {
  margin-bottom: 8px;
}

.script-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 78px;
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  outline: none;
  margin-bottom: 10px;
}

.script-input:focus {
  border-color: var(--accent);
}

.shot-row {
  align-items: center;
  gap: 6px;
}

.shot-row .row-main {
  min-width: 0;
}

.shot-row .row-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 6;
  background: rgba(20, 22, 27, 0.94);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 8px 8px;
  backdrop-filter: blur(8px);
}

.tl-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.tl-dur {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.tl-input {
  width: 48px;
  font: inherit;
  font-size: 11px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 5px;
}

.tl-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tl-track {
  position: relative;
  height: 26px;
  background: #15171c;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
}

.tl-kf {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  margin-top: -4.5px;
  transform: rotate(45deg);
  border-radius: 2px;
  cursor: pointer;
}

.tl-kf.camera {
  background: #ffb454;
}

.tl-kf.actor {
  background: #4fa8ff;
}

.tl-head {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #7ef0c0;
  pointer-events: none;
}

.mini-thumb {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin: 0 0 12px;
}

.scene-thumb {
  display: block;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

.lib {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 9, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.lib-panel {
  width: min(1080px, 94vw);
  height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.lib-title {
  font-size: 14px;
  font-weight: 600;
}

.lib-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.lib-col {
  padding: 12px;
  overflow-y: auto;
}

.lib-left {
  width: 280px;
  border-right: 1px solid var(--line);
  flex: 0 0 auto;
}

.lib-right {
  flex: 1 1 auto;
  min-width: 0;
}

.lib-text {
  min-height: 220px;
}

.lib-file {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.file-input {
  display: none;
}

.lib-range {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.lib-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lib-shots {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.lib-shot {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 6px;
  background: var(--panel-2);
}

.lib-shot-head {
  font-size: 11.5px;
  color: var(--accent);
  margin-bottom: 2px;
}

.lib-shot-body {
  font-size: 12px;
  line-height: 1.5;
}

.lib-actions {
  display: flex;
  gap: 8px;
}

/* hidden 属性必须压过任何 display 声明，否则弹层关不掉 */
[hidden] {
  display: none !important;
}

.lib-status {
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
}

.lib-status.busy {
  color: var(--accent);
}

.lib-status.busy::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% { opacity: 0.25; }
}

.lib-sep {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.row-del {
  margin-left: 6px;
  color: var(--muted);
  padding: 1px 6px;
}

.row-del:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.shot-sub {
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.45;
}

.shot-actions {
  display: flex;
  gap: 8px;
  margin: 4px 0 12px;
}

.shot-text {
  min-height: 110px;
}

.asset-frames {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.asset-frames img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.color-in {
  width: 44px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.check-row .check {
  accent-color: var(--accent);
}

.btn.danger {
  color: #ff8a8a;
  border-color: #5a3238;
}

.btn.danger:hover {
  background: #3a2226;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.char-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-name {
  font-size: 13px;
  font-weight: 600;
}

.char-tags {
  font-size: 11px;
  color: var(--accent);
}

.char-note {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  flex: 1 1 auto;
}

.chip.on {
  background: var(--accent);
  color: #0b0d11;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}

.form-grid .btn {
  padding: 4px 2px;
  font-size: 11px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.board-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
}

.board-thumb {
  aspect-ratio: 16 / 9;
  background: #101216;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

.board-thumb img,
.board-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.board-empty {
  font-size: 11px;
  color: var(--muted);
}

.board-cap {
  padding: 6px 8px 0;
}

.board-name {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-badges {
  display: flex;
  gap: 4px;
  padding: 4px 8px 8px;
  flex-wrap: wrap;
}

.badge.ok {
  color: var(--accent);
  border-color: var(--accent);
}

.pip {
  position: absolute;
  right: 14px;
  bottom: 96px;
  z-index: 7;
  width: 300px;
  background: rgba(18, 20, 25, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.pip img {
  display: block;
  width: 100%;
  border-radius: 4px;
}

.pip-cap {
  font-size: 10.5px;
  color: var(--muted);
  padding: 5px 2px 1px;
  line-height: 1.4;
}

.scene-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.scene-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
}

.scene-chip.on {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(79, 168, 255, 0.12);
}

.scene-del {
  opacity: 0.6;
}

.scene-del:hover {
  opacity: 1;
  color: #ff6b6b;
}

.proj-box {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.proj-label {
  font-size: 11px;
  color: var(--muted);
}

.proj-box .proj-select {
  border: none;
  background: transparent;
  padding: 2px 0;
}

.proj-box .btn.ghost {
  padding: 1px 5px;
}

.guide {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  border: 1px solid rgba(79, 168, 255, 0.35);
  border-radius: 8px;
  background: rgba(79, 168, 255, 0.08);
}

.guide-text {
  flex: 1 1 auto;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text);
}

.guide .btn {
  flex: 0 0 auto;
}

/* 顶栏：给提示文字让位，别把右侧按钮挤出去 */
#topbar {
  gap: 10px;
  overflow: hidden;
}

#topbar > .hint {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#topbar > .actions {
  flex: 0 0 auto;
}

#topbar > .proj-box {
  flex: 0 0 auto;
}

.proj-label {
  white-space: nowrap;
}

#topbar > .seg {
  flex: 0 0 auto;
}

.brand-sub {
  display: none;
}

@media (min-width: 1500px) {
  .brand-sub {
    display: inline;
  }
}

/* 窄屏优先保留按钮，把操作提示收起来 */
@media (max-width: 1460px) {
  #topbar > .hint {
    display: none;
  }
  #topbar {
    gap: 8px;
  }
  #topbar .btn {
    padding: 5px 8px;
  }
}

.menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.menu-list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 230px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  z-index: 50;
}

.menu-wrap.open .menu-list {
  display: block;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 7px 10px;
  font-size: 12px;
}

.menu-item:hover {
  background: var(--panel-3);
  border-radius: 6px;
}

/* 顶栏不能裁，否则下拉菜单会被切掉 */
#topbar {
  overflow: visible;
}

.menu-list {
  max-height: 320px;
  overflow: auto;
}

.set-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--panel-2);
}

.set-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.set-name {
  font-size: 12.5px;
  font-weight: 600;
}

.set-row .lib-range input.text {
  min-width: 120px;
}

.set-row .shot-actions {
  align-items: center;
}

.set-row .shot-actions .btn {
  flex: 0 0 auto;
}

.lib-panel > .hint {
  padding: 8px 14px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.set-row .lib-range input.text {
  flex: 1 1 160px;
  min-width: 120px;
}

.lib-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.lib-panel > .lib-body {
  min-height: 0;
}

.set-row .shot-actions .btn.danger {
  width: auto;
  flex: 0 0 auto;
  padding: 4px 10px;
}

.lib-panel > .lib-col {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  max-height: 260px;
  overflow: auto;
}
