/* Studio 主题：适合编程小白的「浅色课堂工作室」
   原则：高对比正文、柔和分区、单一青绿强调色、少锐角少压迫感 */
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700&display=swap");

:root {
  --bg: #eef2f7;
  --bg-2: #f7f9fc;
  --bg-3: #ffffff;
  --bg-4: #e8eef6;
  --line: #d5dee9;
  --text: #1a2433;
  --fg: var(--text);
  --muted: #66778c;
  --accent: #0f9d8a;
  --accent-soft: #d8f3ee;
  --accent-2: #3b82c4;
  --ok: #1f9d63;
  --bad: #d64545;
  --warn: #c9851a;
  --shadow: 0 1px 2px rgba(26, 36, 51, 0.05), 0 6px 18px rgba(26, 36, 51, 0.06);
  --radius: 10px;
  --radius-sm: 8px;
  --top: 48px;
  --status: 28px;
  --activity: 52px;
  --sidebar: 268px;
  --agent: 340px;
  --timeline: 132px;
  --sash: 5px;
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(15, 157, 138, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(59, 130, 196, 0.07), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* 空闲隐藏滚动条；悬停/聚焦该区域时再显示 */
* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
*:hover,
*:focus,
*:focus-within {
  scrollbar-color: #b7c3d3 transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: transparent;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*:hover::-webkit-scrollbar-thumb,
*:focus::-webkit-scrollbar-thumb,
*:focus-within::-webkit-scrollbar-thumb {
  background-color: #b7c3d3;
  background-clip: padding-box;
}
*:hover::-webkit-scrollbar-thumb:hover,
*:focus-within::-webkit-scrollbar-thumb:hover {
  background-color: #95a6bb;
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--activity) var(--sidebar) var(--sash) minmax(180px, 1fr) var(--sash) var(--agent);
  grid-template-rows: var(--top) minmax(120px, 1fr) var(--timeline) var(--status);
  grid-template-areas:
    "top top top top top top"
    "activity sidebar sash-sb main sash-ag agent"
    "activity sidebar sash-sb timeline sash-ag agent"
    "status status status status status status";
}
.app.no-sidebar { --sidebar: 0px; }
.app.no-agent { --agent: 0px; }
.app.no-timeline { --timeline: 0px; }
.app.resizing { cursor: inherit; user-select: none; }
.app.resizing iframe { pointer-events: none; }

.sash {
  z-index: 25;
  background: transparent;
  transition: background .12s ease;
  position: relative;
}
.sash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
}
.sash:hover,
.sash.dragging {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}
.sash-col {
  cursor: col-resize;
  touch-action: none;
}
.sash-row {
  cursor: row-resize;
  touch-action: none;
}
#sash-sidebar { grid-area: sash-sb; }
#sash-agent { grid-area: sash-ag; }
/* 折叠后仍保留可拖开的细条 */
.app.no-sidebar #sash-sidebar,
.app.no-agent #sash-agent {
  background: color-mix(in srgb, var(--line) 80%, transparent);
}
.app.no-sidebar #sash-sidebar:hover,
.app.no-agent #sash-agent:hover,
.app.no-sidebar #sash-sidebar.dragging,
.app.no-agent #sash-agent.dragging {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

.topbar {
  grid-area: top;
  background: color-mix(in srgb, var(--bg-3) 88%, white);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: var(--top);
  overflow: visible;
  position: relative;
  /* 菜单下拉会溢出到 sidebar/main 网格区；须压过下层以免点击穿透 */
  z-index: 200;
}
.topbar.api-down { box-shadow: inset 0 -2px 0 var(--bad); }
/* 菜单打开时：仅屏蔽菜单下方主工作区，避免点击穿透。
   禁止禁用 .agent：确认卡「应用」必须可点。 */
.app.menu-flyout > .activity,
.app.menu-flyout > .sidebar,
.app.menu-flyout > .main,
.app.menu-flyout > .sash {
  pointer-events: none;
}
.top-left, .top-center, .top-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.top-left { flex: 0 1 auto; }
.top-center { flex: 1 1 auto; justify-content: center; gap: 8px; }
.top-right { flex: 0 0 auto; margin-left: auto; }
.top-view-mode {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-left: 2px;
  margin-right: 6px;
  flex-shrink: 0;
}
.top-view-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 10px;
  line-height: 1.2;
  cursor: pointer;
}
.top-view-btn + .top-view-btn {
  border-left: 1px solid var(--line);
}
.top-view-btn:hover {
  color: var(--text);
  background: var(--bg-4);
}
.top-view-btn.is-on {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-3));
}
.brand-mark {
  width: 22px;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-mark svg { width: 16px; height: 16px; display: block; }
.menubar { display: flex; align-items: stretch; gap: 0; }
.menu { position: relative; }
.menu-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.menu-btn:hover, .menu.open .menu-btn { background: var(--accent-soft); color: var(--accent); }
.menu-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 0;
  z-index: 50;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.menu.open > .menu-drop { display: block; }
.menu-item, .menu-sub > .menu-sub-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  padding: 6px 12px;
  text-align: left;
  border-radius: 0;
}
.menu-item:hover, .menu-sub:hover > .menu-sub-btn { background: var(--bg-4); }
.menu-item:disabled, .menu-sub-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.menu-item .kbd { color: var(--muted); font-size: 11px; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 8px; }
.menu-sub { position: relative; }
.menu-sub-btn { width: 100%; }
.menu-sub-drop {
  display: none;
  position: absolute;
  left: 100%;
  top: -4px;
  min-width: 180px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 0;
  z-index: 60;
  pointer-events: auto;
}
/* 桥接缝隙，避免移入子菜单时 hover 断开导致点击落空 */
.menu-sub-drop::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 0;
  width: 12px;
}
.menu-sub:hover > .menu-sub-drop,
.menu-sub.open > .menu-sub-drop { display: block; }
.menu-sub:has(.menu-sub-btn:disabled):hover > .menu-sub-drop,
.menu-sub:has(.menu-sub-btn:disabled).open > .menu-sub-drop {
  display: none;
}
.menu-sub:has(.menu-sub-btn:disabled) {
  pointer-events: none;
}
.top-project {
  background: transparent;
  border: 0;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-project:hover { background: var(--bg-4); }
.top-icons { display: flex; align-items: center; gap: 2px; }
.top-icons .icon-btn {
  width: 28px;
  height: 28px;
  position: relative;
  color: var(--muted);
}
.top-icons .icon-btn svg { width: 16px; height: 16px; display: block; }
.top-icons .icon-btn.active, .top-icons .icon-btn:hover {
  background: var(--bg-4);
  color: var(--text);
}
.icon-btn .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--warn);
  color: #1a1a1a;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
}
.activity .icon-btn svg { width: 18px; height: 18px; display: block; }
#ep-select.top-ep {
  background: var(--bg-4);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
}
.activity { grid-area: activity; background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 6px; }
.sidebar { grid-area: sidebar; background: var(--bg-3); border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; min-width: 0; box-shadow: inset -1px 0 0 rgba(255,255,255,.6); }
.main { grid-area: main; background: var(--bg-3); overflow: hidden; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow); }
.agent { grid-area: agent; background: var(--bg-3); border-left: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.timeline { grid-area: timeline; background: var(--bg-2); border-top: 1px solid var(--line); overflow: auto; }
.statusbar { grid-area: status; background: var(--bg-2); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 12px; color: var(--muted); }

.brand { font-weight: 700; letter-spacing: .01em; color: var(--accent); margin-right: 8px; }
.sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.btn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,.8);
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 80%, #0a6f62);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 157, 138, 0.28);
}
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #0a6f62); }
.btn.danger { background: #fff5f5; border-color: #f0b4b4; color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: #ffe8e8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-sm); }
.icon-btn.active, .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.grow { flex: 1; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.ok { color: var(--ok); }

.bible-drop-row.drop-hover,
.bible-drop-row.drop-hover td {
  outline: 1px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
#sidebar.drop-target,
#agent.drop-target {
  outline: 2px dashed var(--accent, #d4a056);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--accent, #d4a056) 8%, transparent);
}
.side-head, .agent-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); font-size: 13px; min-height: 40px;
  background: color-mix(in srgb, var(--bg-2) 70%, white);
}
.agent-head {
  flex-wrap: nowrap;
  align-items: center;
  max-height: none;
  /* 须 visible：overflow-y:hidden / overflow-x:auto 会裁掉 ⋯ 与会话下拉 */
  overflow: visible;
  flex-shrink: 0;
  row-gap: 0;
  position: relative;
  /* 高于 agent-context / agent-body，避免下拉被下一行盖住 */
  z-index: 20;
}
.agent-head > .grow {
  flex: 1 1 auto;
  min-width: 8px;
}
.agent-head-title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-head-title .muted { font-weight: 400; }
.agent-head .agent-status {
  flex: 0 0 auto;
}
.agent-head .agent-status.is-busy {
  color: var(--warn, #e6b84d);
}
.agent-art-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  max-width: 9.5em;
  padding: 1px 6px 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.agent-art-chip-k {
  flex-shrink: 0;
  opacity: 0.75;
}
.agent-art-chip select {
  max-width: 7em;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
}
.agent-art-chip select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.agent-head .agent-session {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0;
  flex: 0 1 160px;
  position: relative;
}
.agent-head .agent-session-toggle {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--panel-2, var(--bg));
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}
.agent-head .agent-session-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.agent-head .agent-session-toggle .sess-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-head .agent-session-toggle .sess-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}
.agent-session-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 220px;
  max-height: min(360px, 50vh);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
}
.agent-session-panel.hidden { display: none; }
.agent-session-panel input[type="search"] {
  width: 100%;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: inherit;
}
.agent-session-list {
  overflow: auto;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.agent-session-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.agent-session-item:hover { background: var(--bg-4); }
.agent-session-item.is-active {
  border-color: var(--accent, #d4a056);
  background: color-mix(in srgb, var(--accent, #d4a056) 12%, transparent);
}
.agent-session-item .sess-pick {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 2px 0;
  font-size: 12px;
}
.agent-session-item .sess-pick-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-session-item .sess-pick-meta {
  display: block;
  font-size: 10px;
  color: var(--muted);
}
.agent-session-item .sess-ops {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}
.agent-session-item .sess-ops button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
}
.agent-session-item .sess-ops button:hover { background: var(--bg); color: inherit; }
.agent-session-item .sess-ops button:disabled { opacity: 0.4; cursor: not-allowed; }
.agent-session-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px;
}
.agent-more {
  position: relative;
  flex: 0 0 auto;
}
.agent-more > summary {
  list-style: none;
  cursor: pointer;
}
.agent-more > summary::-webkit-details-marker { display: none; }
.agent-more-drop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 148px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.agent-more[open] {
  z-index: 41;
}
.agent-more-drop button {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.agent-more-drop button:hover:not(:disabled) { background: var(--bg-4); }
.agent-more-drop button:disabled { opacity: 0.45; cursor: not-allowed; }
.agent-queue-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  background: color-mix(in srgb, var(--accent, #d4a056) 14%, var(--bg-2));
  border-bottom: 1px solid var(--line);
}
.agent-queue-banner .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-queue-banner button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.agent-queue-banner button:hover { background: var(--bg-4); color: inherit; }
/* Cursor：composer 上方排队托盘 */
.agent-queue-tray {
  margin: 0;
  border-top: 1px solid var(--line);
  background: var(--bg-2, #161b22);
  font-size: 12px;
  color: var(--muted);
}
.agent-queue-tray > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--muted);
  font-weight: 500;
}
.agent-queue-tray > summary::-webkit-details-marker { display: none; }
.agent-queue-tray > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted, #8b949e);
  flex-shrink: 0;
  opacity: 0.7;
  transform: rotate(-90deg);
  transition: transform .12s ease;
}
.agent-queue-tray[open] > summary::before { transform: rotate(0deg); }
.agent-queue-tray-title { color: var(--text); font-size: 12px; }
.agent-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px 10px;
}
.agent-queue-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-3, rgba(255,255,255,.04));
  border: 1px solid var(--line);
}
.agent-queue-item-text {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.2em;
  overflow: hidden;
}
.agent-queue-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.agent-queue-act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.agent-queue-act:hover { background: var(--bg-4); color: var(--text); }
.agent-queue-send-now {
  color: var(--accent, #d4a056);
  font-weight: 500;
}
.agent-queue-send-now:hover { color: var(--text); }
.agent-model-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 140px;
  font-size: 12px;
  color: var(--text);
  border: 0;
  background: var(--bg-4, rgba(255,255,255,.06));
  cursor: pointer;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  line-height: 1.2;
}
.agent-model-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}
.agent-model-chip:hover { background: var(--bg-3, rgba(255,255,255,.1)); }
.agent-model-wrap {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
}
.agent-model-wrap.is-open > .agent-model-chip {
  background: var(--bg-3, rgba(255,255,255,.12));
}
.agent-model-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  min-width: min(240px, 70vw);
  max-width: min(320px, 85vw);
  max-height: min(280px, 45vh);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.38);
}
.agent-model-menu.hidden { display: none; }
.agent-model-opt {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-model-opt:hover { background: var(--bg-4); }
.agent-model-opt.is-on { background: var(--bg-4); }
.agent-model-opt.agent-model-settings {
  margin-top: 2px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  color: var(--muted);
}
.agent-model-empty {
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
}
.tabbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  min-height: 34px;
  max-height: 36px;
  min-width: 0;
  overflow: hidden;
  flex-shrink: 0;
}
/* 旧三段按钮隐藏；改用 Cursor pill 下拉 */
.agent-mode { display: none !important; }
.agent-mode-wrap {
  position: relative;
  flex: 0 0 auto;
}
.agent-mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: var(--bg-4, rgba(255,255,255,.06));
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}
.agent-mode-chip:hover { background: var(--bg-3, rgba(255,255,255,.1)); }
.agent-mode-chip:disabled { opacity: 0.5; cursor: not-allowed; }
.agent-mode-wrap.is-open > .agent-mode-chip {
  background: var(--bg-3, rgba(255,255,255,.12));
}
.agent-mode-ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}
.agent-mode-ico.is-glyph {
  width: auto;
  height: auto;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
}
.agent-mode-chevron {
  width: 12px;
  height: 12px;
  opacity: 0.7;
  flex-shrink: 0;
}
.agent-mode-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 45;
  min-width: 168px;
  padding: 6px;
  background: #fff;
  color: #1f2328;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.agent-mode-menu.hidden { display: none; }
.agent-mode-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}
.agent-mode-opt:hover { background: #f0f2f4; }
.agent-mode-opt.is-on { background: #eef0f2; }
.agent-mode-opt:disabled { opacity: 0.45; cursor: not-allowed; }
.agent-mode-opt-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.agent-mode-opt .agent-mode-ico { color: #424a53; }
.agent-mode-check {
  width: 14px;
  height: 14px;
  color: #1f2328;
  flex-shrink: 0;
}
.agent-send-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--text, #e6edf3);
  color: var(--bg, #0d1117);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.agent-send-btn:hover { filter: brightness(1.08); }
.agent-send-btn.is-stop {
  background: var(--text, #e6edf3);
  color: var(--bg, #0d1117);
}
.agent-send-btn.is-stop:hover { filter: brightness(0.92); }
.msg.user .msg-body { cursor: text; }

.agent-plan-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.5rem 0 0.25rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  background: var(--bg-3);
}
.agent-plan-card .agent-plan-apply {
  font-weight: 600;
}
.agent-plan-card .muted {
  font-size: 0.85em;
  opacity: 0.8;
}
/* P1 Plan 文档化：可编辑计划卡（步骤勾选 + 文本编辑 + 存档） */
.agent-plan-card.is-editable {
  display: block;
}
.agent-plan-id { font-weight: 400; font-size: 11px; margin-left: 8px; }
.agent-plan-summary { font-size: 12px; margin-bottom: 6px; }
.agent-plan-alts { margin: 4px 0 8px; font-size: 12px; }
.agent-plan-alt { margin: 2px 0; padding-left: 2px; }
.agent-plan-step-status {
  width: 1.1em;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  flex: 0 0 auto;
}
.agent-plan-step.is-done .agent-plan-step-status { color: var(--ok, #3d9a5f); }
.agent-plan-step.is-running .agent-plan-step-status { color: var(--accent, #4c8bf5); }
.agent-plan-rerun,
.agent-plan-refine {
  font-size: 12px;
}
.agent-plan-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 0 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2, var(--bg-elevated, #1a1a1a));
  color: var(--text);
}
.agent-plan-suggest .btn { font-size: 12px; }
.agent-mode-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  font-size: 12px;
}
.agent-mode-cta .btn { font-size: 12px; }
.agent-plan-steps { list-style: none; margin: 4px 0; padding: 0; counter-reset: planstep; }
.agent-plan-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.agent-plan-step.is-skipped .agent-plan-step-input {
  text-decoration: line-through;
  opacity: 0.55;
}
.agent-plan-step-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 2px 4px;
}
.agent-plan-step-input:hover { border-color: var(--border); }
.agent-plan-step-input:focus { border-color: var(--text); outline: none; }
.agent-plan-gating { font-size: 11px; color: var(--warn, #e6b84d); margin-top: 2px; }
.agent-plan-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 6px;
}
.agent-plan-save {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}
.agent-plan-save:hover { color: var(--text); border-color: var(--text); }
/* P2 Agent Review：回合后审查卡 */
.agent-review-card {
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  background: var(--bg-3);
}
.agent-review-card.is-warn { border-color: var(--warn, #e6b84d); }
.agent-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.agent-review-card.is-warn .agent-review-head strong { color: var(--warn, #e6b84d); }
.agent-review-deep {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  padding: 1px 6px;
  cursor: pointer;
}
.agent-review-deep:hover { color: var(--text); border-color: var(--text); }
.agent-review-list { margin: 6px 0 0; padding-left: 16px; }
.agent-review-list li { margin: 2px 0; }
.agent-review-excerpt { color: var(--muted); margin-left: 4px; }
.side-body, .agent-body, .main-body { flex: 1; overflow: auto; padding: 8px; min-height: 0; }
.main-body {
  display: flex;
  flex-direction: column;
}
.main-body:has(> .settings-form) {
  padding: 0;
  overflow: hidden;
}
/* 画布模式：#main 整区铺满，无标签栏与内边距 */
#main.is-canvas-mode {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#main.is-canvas-mode .main-body-canvas {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#main.is-canvas-mode .studio-unified-canvas-sec,
#main.is-canvas-mode .studio-canvas {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
}
#main.is-canvas-mode .studio-canvas-viewport {
  flex: 1 1 auto;
  min-height: 0;
}
.main-body.is-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.main-body.is-split .pane {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.main-body.is-split .pane-split { border-right: 0; }
.main-body .pane-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.tabbar .tab.is-split { box-shadow: inset 0 -2px 0 var(--accent-2, #6ea8ff); }
.toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.toolbar .toolbar-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}
.toolbar .studio-canvas-mode {
  flex: 0 0 auto;
}
.filter { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; margin-bottom: 8px; }

.tree details { margin-left: 5px; }
.tree-dir { margin-left: 5px; }
.tree-dir > .tree-children { margin-left: 15px; }
.tree-dir > .tree-children.hidden { display: none; }
.tree-dir-row, .tree .file {
  display: flex;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.tree-twist {
  flex: 0 0 auto;
  width: 0.9em;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}
.tree-twist::before { content: "▸"; }
.tree-dir.is-open > .tree-dir-row > .tree-twist::before { content: "▾"; }
.tree summary, .tree .file {
  display: flex;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}
.tree summary {
  list-style: none;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::marker { content: ""; }
.tree summary::before {
  content: "▸";
  flex: 0 0 auto;
  width: 0.9em;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}
.tree details[open] > summary::before {
  content: "▾";
}
.tree .file.selected, .tree summary:hover, .tree .file:hover,
.tree-dir-row:hover { background: var(--bg-4); }
.tree-count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  flex: 0 0 auto;
}
.tree-fname {
  color: var(--muted);
  font-size: 11px;
  opacity: 0.9;
  flex: 0 0 auto;
}
.tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shot-item, .stage-item {
  padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; font-size: 12px;
}
.shot-item.selected, .stage-item.active { border-color: var(--accent); }
.qc-pass { border-left: 3px solid var(--ok); }
.qc-fail { border-left: 3px solid var(--bad); }
.qc-none { border-left: 3px solid var(--muted); }
.hitl { color: var(--warn); }

.tabbar .tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tabbar .tabs::-webkit-scrollbar { height: 4px; }
.tabbar .tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.tabbar .tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 132px;
  padding: 4px 8px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  line-height: 1.3;
  cursor: pointer;
}
.tabbar .tab .tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tabbar .tab [data-close] {
  flex-shrink: 0;
  opacity: 0.65;
  padding: 0 2px;
}
.tabbar .tab [data-close]:hover { opacity: 1; color: var(--bad, #e88); }
.tabbar.is-compact .tab { max-width: 72px; font-size: 11px; padding: 4px 6px; }
.tabbar .tab.active { background: var(--bg-4); color: var(--text); }
.preview { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px; }
.preview img, .preview video {
  max-height: calc(100% - 40px); max-width: 100%; background: #000; display: block; margin: 12px auto;
}
.preview.portrait video, .preview.portrait img { width: min(360px, 100%); aspect-ratio: 9/16; object-fit: contain; }
.preview.portrait {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.preview.portrait > .muted {
  text-align: center;
  margin: 8px 0 0;
}
.kf-preview-wrap {
  position: relative;
  width: min(360px, 100%);
  margin: 12px auto;
  display: block;
  aspect-ratio: 9 / 16;
  background: #0b0c0f;
  overflow: hidden;
  flex: 0 0 auto;
}
.preview-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 5;
  pointer-events: auto;
}
.preview-toolbar-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.preview-toolbar-btn:hover:not([disabled]) {
  background: rgba(0, 0, 0, 0.75);
}
.preview-toolbar-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.vision-describe-dialog {
  width: min(560px, 90vw);
  border: 1px solid var(--line, #2a2d33);
  border-radius: 12px;
  background: var(--bg, #14161a);
  color: var(--text, #e6e8ec);
  padding: 0;
}
.vision-describe-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.vision-describe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line, #2a2d33);
  margin: 0;
}
.vision-describe-head strong {
  font-size: 13px;
  font-weight: 600;
}
.vision-describe-body {
  padding: 14px;
  min-height: 100px;
  max-height: 60vh;
  overflow: auto;
}
.vision-describe-body[data-state="loading"] {
  opacity: 0.7;
}
.vision-describe-text {
  white-space: pre-wrap;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}
.vision-describe-model {
  margin-top: 10px;
  font-size: 12px;
}
.vision-describe-error {
  color: #f85149;
  font-size: 13px;
}
/* 画幅由 wrap 承担；取消 .preview img 的 max-height，避免 16:9 框被压扁露出黑边 */
.preview.portrait .kf-preview-wrap img {
  width: 100%;
  height: 100%;
  margin: 0;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
  display: block;
  background: transparent;
}
.kf-edit-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.preview.portrait.kf-editing .kf-preview-wrap {
  margin: 12px 0;
  flex: 0 0 auto;
}
.kf-edit-overlay {
  position: absolute; inset: 0; cursor: crosshair; z-index: 3;
  touch-action: none; user-select: none;
}
.kf-edit-rect {
  position: absolute; border: 2px solid var(--accent); background: rgba(212,160,86,.2); pointer-events: none;
}
.kf-edit-panel {
  position: sticky;
  top: 12px;
  z-index: 4;
  width: min(300px, 100%);
  flex: 1 1 240px;
  max-width: 320px;
  margin: 12px 0;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: none;
}
.kf-edit-panel label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.kf-edit-panel textarea, .kf-edit-panel select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; color: var(--text); resize: vertical;
}
.kf-edit-actions { display: flex; gap: 6px; }
@media (max-width: 720px) {
  .kf-edit-layout { flex-direction: column; align-items: center; }
  .kf-edit-panel {
    position: static;
    max-width: min(360px, 100%);
    width: min(360px, 100%);
  }
}
.md h1, .md h2, .md h3 { color: var(--accent); }
.md h1 { font-size: 1.35em; margin: 0.4em 0 0.3em; }
.md h2 { font-size: 1.2em; margin: 0.4em 0 0.25em; }
.md h3 { font-size: 1.05em; margin: 0.35em 0 0.2em; }
.md p { margin: 0.35em 0; }
.md ul, .md ol { margin: 0.35em 0; padding-left: 1.3em; }
.md li { margin: 0.15em 0; }
.md blockquote {
  margin: 0.4em 0; padding: 0.4em 0.8em; border-left: 3px solid var(--accent);
  color: var(--muted); background: var(--accent-soft);
}
.md hr { border: 0; border-top: 1px solid var(--line); margin: 0.6em 0; }
.md code {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.9em;
  background: var(--bg-4); color: #234; padding: 0.12em 0.4em; border-radius: 6px;
}
.md pre {
  background: #1f2937; color: #e8eef6; border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--radius-sm);
  overflow: auto; margin: 0.5em 0;
}
.md pre code { background: transparent; padding: 0; font-size: 12px; white-space: pre-wrap; }
.md-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 0.5em 0; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md-table th { background: var(--bg-4); }
.msg-body .agent-md { font-size: 13px; line-height: 1.5; }
.msg-body .agent-md a.agent-path { color: var(--accent); text-decoration: underline; word-break: break-all; }
.msg-body .agent-md pre {
  max-height: 280px;
  overflow: auto;
  border-left: 3px solid var(--line);
}
.msg-body .agent-md strong {
  color: var(--accent);
  font-weight: 650;
}
.msg-body .agent-md p > strong:only-child {
  display: inline-block;
  margin-top: 0.35em;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.msg.dir .hl-shot { color: var(--accent); font-weight: 600; }
.msg.dir .hl-camera { color: var(--accent-2); }
.msg.dir .hl-motion { color: #0f9d8a; }
.msg.dir .hl-field {
  color: #6b5b3e;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
}
.msg.dir .hl-plan { color: var(--warn); font-weight: 600; }
.msg.dir .hl-beat { color: var(--ok); }
.md pre, textarea.code, pre.code, .json-view {
  background: #1f2937; color: #e8eef6; border: 1px solid var(--line); padding: 12px; border-radius: var(--radius-sm);
  white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
}
pre.code.preview-readonly {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin: 0;
}
textarea.code {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  resize: none;
  align-self: stretch;
}
/* 仅在高亮叠加编辑器内透明字色；裸 textarea 仍可见。
 * 选区也保持透明字：只画强调色底。若选区恢复可见色，会与下层高亮叠成「鬼影/镂空」。
 * 完整复制依赖 studio.js 的 copy/cut 拦截（从 value 写剪贴板）。 */
.code-editor textarea.code {
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  background: transparent;
  user-select: text;
}
.code-editor textarea.code::selection,
.code-editor textarea.code::-moz-selection {
  color: transparent;
  -webkit-text-fill-color: transparent;
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

/* 源码编辑器：与 Studio 浅色主体同系（白底 + 线框 + 柔和 gutter） */
.code-editor {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  width: 100%;
  align-self: stretch;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.code-editor .code-stack {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-3);
}
.code-editor .code-gutter {
  flex: 0 0 auto;
  width: 44px;
  padding: 12px 6px 12px 8px;
  overflow: hidden;
  text-align: right;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  user-select: none;
  white-space: pre;
}
.code-editor .code-gutter-ln {
  display: block;
  min-height: 1.55em;
}
.code-editor .code-gutter-ln.is-add {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.code-editor .code-highlight .code-hl-line {
  display: block;
  min-height: 1.55em;
}
.code-editor .code-highlight .code-line-add {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.code-editor.is-reviewing {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
}
.file-review-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin: 0 0 8px;
  background: var(--bg-2, #161b22);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.file-review-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.file-review-nav-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted, #8b949e);
  padding: 2px 4px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.file-review-nav-btn:hover:not(:disabled) {
  color: var(--text, #e6edf3);
  background: rgba(255, 255, 255, 0.06);
}
.file-review-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.file-review-nav-label {
  font-size: 12px;
  color: var(--muted, #8b949e);
  min-width: 3.5em;
  text-align: center;
  white-space: nowrap;
  user-select: none;
}
.file-review-nav-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  flex: 0 0 auto;
  margin: 0 2px;
}
.file-review-bar .grow { flex: 1; min-width: 0; }
.file-review-bar kbd {
  font-size: 10px;
  opacity: 0.75;
  margin-left: 4px;
  font-family: inherit;
}
.file-review-undo {
  background: var(--bg, #0d1117);
  border: 1px solid var(--line);
}
.main-body.has-file-review {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.file-review-diff {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2, #161b22);
  padding: 8px 0 12px;
}
.file-review-diff-hint {
  margin: 0 12px 8px;
  font-size: 12px;
}
.file-review-diff .agent-diff-body {
  max-height: none;
  min-height: 100%;
}
.file-review-diff .agent-diff-line.is-focus {
  outline: 1px solid var(--accent, #d4a056);
  outline-offset: -1px;
}
.code-editor .code-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  /* 禁折行：与 gutter 按 \\n 计行 1:1；pre-wrap 会长段折行导致行号错位、选区镂空 */
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  color: var(--text);
  pointer-events: none;
  background: transparent;
  border: none;
  border-radius: 0;
}
.code-editor .code-highlight code {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  display: block;
  min-height: 100%;
  padding: 0;
  white-space: inherit;
}
.code-editor textarea.code {
  position: relative;
  z-index: 1;
  border: none;
  border-radius: 0;
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  overflow: auto;
  tab-size: 2;
}

/* 浅色主体上的语法高亮（编辑器 + Agent diff 共用） */
.code-highlight .tok-keyword,
.agent-diff-text .tok-keyword { color: #7c3aed; }
.code-highlight .tok-string,
.agent-diff-text .tok-string { color: #0f766e; }
.code-highlight .tok-number,
.agent-diff-text .tok-number { color: #b45309; }
.code-highlight .tok-comment,
.agent-diff-text .tok-comment { color: var(--muted); font-style: italic; }
.code-highlight .tok-literal,
.agent-diff-text .tok-literal { color: #2563eb; }
.code-highlight .tok-heading,
.agent-diff-text .tok-heading { color: #1d4ed8; font-weight: 600; }
.code-highlight .tok-link,
.agent-diff-text .tok-link { color: #2563eb; text-decoration: underline; }
.code-highlight .tok-tag,
.agent-diff-text .tok-tag { color: #0f766e; }
.code-highlight .tok-key,
.agent-diff-text .tok-key { color: #0369a1; }
.code-highlight .tok-meta,
.agent-diff-text .tok-meta { color: var(--muted); }
.code-highlight .tok-quote,
.agent-diff-text .tok-quote { color: var(--muted); font-style: italic; }
.code-highlight .tok-code,
.agent-diff-text .tok-code { color: #0f766e; }
.code-highlight .tok-var,
.agent-diff-text .tok-var { color: #0369a1; }
.code-highlight .hljs-keyword,
.agent-diff-text .hljs-keyword { color: #7c3aed; }
.code-highlight .hljs-string,
.agent-diff-text .hljs-string { color: #0f766e; }
.code-highlight .hljs-number,
.agent-diff-text .hljs-number { color: #b45309; }
.code-highlight .hljs-comment,
.agent-diff-text .hljs-comment { color: var(--muted); font-style: italic; }
.code-highlight .hljs-literal,
.agent-diff-text .hljs-literal,
.code-highlight .hljs-built_in,
.agent-diff-text .hljs-built_in { color: #2563eb; }
.code-highlight .hljs-title,
.agent-diff-text .hljs-title,
.code-highlight .hljs-name,
.agent-diff-text .hljs-name { color: #7c3aed; }
.code-highlight .hljs-attr,
.agent-diff-text .hljs-attr { color: #0369a1; }
.code-highlight .hljs-meta,
.agent-diff-text .hljs-meta { color: var(--muted); }
.code-highlight .hljs-tag,
.agent-diff-text .hljs-tag { color: #0f766e; }
.json-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.sb-hint { flex: 0 0 auto; margin: 0 0 8px; font-size: 12px; }
.sb-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
.sb-wrap:has(.card-deck) { overflow: hidden; display: flex; flex-direction: column; }
.sb-wrap > .card-deck { flex: 1 1 auto; min-height: 0; }
.board-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.board-aspect-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.board-aspect-field > span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.board-aspect-field select {
  min-width: 7.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}
.board-aspect-hint { font-size: 11px; }
.board-toolbar .studio-canvas-mode {
  margin-left: auto;
}
.board-cards.board-canvas-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.board-cards.board-canvas-wrap .studio-canvas {
  flex: 1 1 auto;
  min-height: 0;
}
.board-cards[data-aspect="16:9"] .preview.portrait video,
.board-cards[data-aspect="16:9"] .preview.portrait img {
  aspect-ratio: 16 / 9;
  width: min(420px, 100%);
}
.board-cards[data-aspect="1:1"] .preview.portrait video,
.board-cards[data-aspect="1:1"] .preview.portrait img {
  aspect-ratio: 1 / 1;
  width: min(320px, 100%);
}
/* 分镜卡右侧预览：跟随工程画幅（勿写死竖屏） */
.board-cards[data-aspect="16:9"] .shot-preview {
  aspect-ratio: 16 / 9;
  min-height: 160px;
}
.board-cards[data-aspect="1:1"] .shot-preview {
  aspect-ratio: 1 / 1;
  min-height: 180px;
}
/* 媒体 Tab（关键帧/成片/主体）：画幅跟 data-aspect，由 wrap 定框 */
.preview.portrait[data-aspect="16:9"] > video,
.preview.portrait[data-aspect="16:9"] > img {
  aspect-ratio: 16 / 9;
  width: min(720px, 100%);
}
.preview.portrait[data-aspect="16:9"] .kf-preview-wrap {
  width: min(720px, 100%);
  aspect-ratio: 16 / 9;
}
.preview.portrait[data-aspect="1:1"] > video,
.preview.portrait[data-aspect="1:1"] > img {
  aspect-ratio: 1 / 1;
  width: min(480px, 100%);
}
.preview.portrait[data-aspect="1:1"] .kf-preview-wrap {
  width: min(480px, 100%);
  aspect-ratio: 1 / 1;
}
.bible-edit {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.bible-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.bible-section h3 {
  flex: 0 0 auto;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--accent);
}
.bible-section-head {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 6px;
}
.bible-section-head h3 {
  margin: 0;
}
.bible-section-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.studio-canvas-adds {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.studio-canvas-adds .btn {
  padding: 3px 10px;
  font-size: 12px;
}
.bible-section .sb-wrap,
.bible-section .card-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}
.bible-section .card-list.card-deck {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.bible-section-only .bible-chars,
.bible-section-only .bible-locs,
.bible-section-only .bible-props,
.bible-section-only .bible-rules-sec {
  flex: 1 1 0;
}
.bible-edit table.grid textarea {
  min-height: 72px;
  resize: vertical;
}
.bible-edit #bible-locs textarea,
.bible-edit #bible-props textarea {
  min-height: 64px;
}
.bible-rules {
  width: calc(100% - 4px);
  flex: 1 1 auto;
  min-height: 160px;
  height: auto;
  resize: vertical;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
table.grid.board-grid {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px; vertical-align: top; }
table.grid.board-grid th {
  position: relative;
  overflow: visible;
  user-select: none;
}
table.grid.board-grid .th-label { display: inline-block; max-width: calc(100% - 4px); overflow: hidden; text-overflow: ellipsis; }
table.grid.board-grid .col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
table.grid.board-grid .col-resizer::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 3px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
}
table.grid.board-grid th:hover .col-resizer::after,
table.grid.board-grid .col-resizer.dragging::after {
  background: var(--accent, #6ea8fe);
}
table.grid.board-grid .col-resizer.dragging { background: color-mix(in srgb, var(--accent, #6ea8fe) 18%, transparent); }
table.grid input, table.grid textarea, table.grid select { width: 100%; background: var(--bg); border: 0; }
.sb-char-hint { margin: 8px 0 0; font-size: 11px; word-break: break-all; }

.id-picker {
  display: block;
  min-width: 0;
  overflow: visible;
}
.id-picker-box {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 34px;
  padding: 4px 6px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-sizing: border-box;
}
.id-picker-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
.id-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 24px;
  align-items: center;
}
.id-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 1px 4px 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2, var(--bg));
  font-size: 11px;
  line-height: 1.4;
}
.id-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 9em;
}
.id-chip-x {
  border: 0;
  background: transparent;
  color: var(--muted, #888);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-size: 12px;
}
.id-chip-x:hover { color: var(--fg, #222); }
.id-picker-empty { font-size: 11px; color: var(--muted); }

/* 关联场景互锁编辑器（地点卡） */
.related-locs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-height: 22px;
  margin-top: 4px;
}
.related-locs-empty {
  font-size: 11px;
  color: var(--muted);
}
.related-locs-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 8px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
}
.related-locs-add:hover { color: var(--text); border-color: var(--accent-2); }
.related-locs-menu {
  position: absolute;
  z-index: 30;
  min-width: 180px;
  max-height: 240px;
  overflow: auto;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.related-locs-menu .item {
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.related-locs-menu .item:hover { background: var(--bg-4); }
.related-locs-menu .item.disabled { color: var(--muted); cursor: not-allowed; }
.related-locs-menu .item .item-id { color: var(--muted); font-family: monospace; }
.related-locs-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.hitl-review-banner {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(212, 160, 86, 0.08);
  font-size: 12px;
  color: var(--text);
}

/* 关联场景建议卡（LLM 一次性产出） */
.related-suggest-block {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(212, 160, 86, 0.05);
}
.related-suggest-block h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.suggest-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  font-size: 12px;
}
.suggest-pair { flex: 0 0 auto; }
.suggest-reason { flex: 1 1 auto; font-size: 11px; }
.suggest-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.suggest-foot {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.id-picker-menu {
  position: relative;
  z-index: 5;
  overflow: visible;
  flex: 0 0 auto;
  align-self: center;
}
.id-picker-menu > summary,
.id-picker-toggle {
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  color: var(--accent, #3d6ea8);
  user-select: none;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.id-picker-menu > summary:hover,
.id-picker-toggle:hover {
  border-color: var(--line);
  background: var(--bg-2);
}
.id-picker-menu > summary::-webkit-details-marker { display: none; }
.id-picker-menu[open] > summary {
  border-color: var(--line);
  background: var(--bg-2);
}
/* 下拉：输入框下方展开 */
.id-picker-list {
  position: absolute;
  z-index: 40;
  right: 0;
  left: auto;
  top: calc(100% + 4px);
  box-sizing: border-box;
  width: min(280px, 70vw);
  min-width: 200px;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-3, var(--bg));
  box-shadow: 0 8px 24px color-mix(in srgb, #000 28%, transparent);
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}
.id-picker-opt {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.35;
  writing-mode: horizontal-tb;
}
.id-picker-opt:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.id-picker-opt input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-width: 14px;
  max-width: 14px;
  flex: 0 0 14px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent, #3d6ea8);
  cursor: pointer;
}
.id-picker-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}
.id-picker-id {
  flex: 0 0 auto;
  font-size: 10px;
  white-space: nowrap;
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid.board-grid td {
  overflow: visible;
}
.board-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}
.board-actions .btn { width: 100%; white-space: nowrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--bg-3); cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s ease, transform .12s ease; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); transform: translateY(-1px); }
.card img { width: 100%; border-radius: 6px; background: #000; }

.msg { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; line-height: 1.55; position: relative; border: none; }
.msg.user {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 14px;
  padding: 12px 14px;
}
.msg.user .msg-user-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.msg.user .msg-user-row > .msg-body {
  flex: 1;
  min-width: 0;
}
.msg.user .msg-ops-inline {
  margin-top: 0;
  flex-shrink: 0;
  opacity: 0.4;
  align-self: flex-end;
}
.msg.user:hover .msg-ops-inline,
.msg.user:focus-within .msg-ops-inline,
.msg.user.ops-open .msg-ops-inline {
  opacity: 1;
}
.msg.user .msg-ops-inline .msg-menu-drop {
  right: 0;
  left: auto;
}
.msg.dir {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  padding-left: 0;
  padding-right: 0;
}
.msg.system { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 12px; }

.msg-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  margin-top: 8px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  opacity: 0.55;
  pointer-events: auto;
  transition: opacity .12s ease;
  z-index: 2;
}
.msg-ops-dir {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  opacity: 1;
}
.msg-ops-dir .msg-ops-actions {
  opacity: 1;
}
.msg-ops-dir .msg-ops-time {
  margin-left: 2px;
  opacity: 0.72;
  font-size: 12px;
  color: var(--muted);
}
/* 分叉等图标：悬停气泡说明（非独立按钮）；左对齐避免超出 Agent 栏左缘 */
.msg-op-btn[data-tip] {
  position: relative;
}
.msg-op-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  transform: translateY(2px);
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line, rgba(0, 0, 0, 0.12));
  background: var(--bg-2, #fff);
  color: var(--text, #1f2328);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  z-index: 20;
}
.msg-op-btn[data-tip]:hover::after,
.msg-op-btn[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}
.msg-op-btn[data-tip]:disabled::after {
  display: none;
}
.msg:hover .msg-ops,
.msg:focus-within .msg-ops,
.msg.ops-open .msg-ops {
  opacity: 1;
}
.msg-ops-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.msg-op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #8b949e);
  cursor: pointer;
}
.msg-op-btn:hover {
  background: var(--bg-3, rgba(255,255,255,.06));
  color: var(--fg, #e6edf3);
}
.msg-op-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.msg-op-ico {
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
}
.msg-ops-time {
  font-size: 11px;
  color: var(--muted, #8b949e);
  user-select: none;
  margin-left: 4px;
}
.msg-ops .btn {
  font-size: 11px;
  padding: 2px 6px;
  background: transparent;
  border-color: transparent;
}
.msg-ops .btn:hover { background: var(--bg-4); border-color: var(--line); }
.msg-menu { position: relative; }
.msg-menu-drop {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 2px;
  min-width: 140px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 0;
  z-index: 5;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.msg-menu.open > .msg-menu-drop { display: block; }
.msg-menu-drop button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  padding: 6px 12px;
}
.msg-menu-drop button:hover { background: var(--bg-4); }
.msg-menu-drop button:disabled { opacity: .45; cursor: not-allowed; }

.agent-actions { margin-top: 8px; font-size: 11px; color: var(--muted); }
.agent-actions summary { cursor: pointer; user-select: none; }
.agent-actions-brief { color: var(--text); opacity: 0.85; }
.agent-actions ul { list-style: none; margin: 6px 0 0; padding: 0; }
.agent-action-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
}
.agent-action-row > span { flex: 1 1 auto; min-width: 0; }
.agent-action-row.status-rejected span,
.agent-action-row.status-skipped span { color: var(--muted); }
/* P0 轨迹 UX：失败动作红色着色（不再灰色弱化），并提供重试入口 */
.agent-action-row.status-error span { color: var(--danger, #e07070); }
.agent-action-row.status-error .agent-action-retry {
  color: var(--danger, #e07070);
  border-color: var(--danger, #e07070);
}
.agent-action-retry {
  border: 1px solid var(--border, #444);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  padding: 0 6px;
  cursor: pointer;
}
.agent-action-retry:hover { color: var(--text); border-color: var(--text); }
.agent-action-row.status-ok span { color: var(--text); }
/* P0 轨迹 UX：探索动作折叠一行 */
.agent-explore-row {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-explore-brief { opacity: 0.85; }
.agent-action-raw { margin-left: auto; flex-shrink: 0; }
.agent-action-raw summary {
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  user-select: none;
  list-style: none;
}
.agent-action-raw summary::-webkit-details-marker { display: none; }
.agent-action-raw:not([open]) summary::before { content: "⋯"; }
.agent-action-raw[open] summary::before { content: ""; }
.agent-action-raw[open] summary { color: inherit; }
.agent-action-raw pre {
  margin: 4px 0 0;
  max-height: 120px;
  overflow: auto;
  font-size: 10px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-confirm {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}
.agent-confirm-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 6px;
}
.agent-confirm-diff {
  margin: 0 0 8px;
  padding: 8px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
  line-height: 1.45;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}
.agent-files-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  font-size: 12px;
  flex-wrap: wrap;
}
.agent-files-bar .grow { flex: 1; min-width: 0; }
.agent-files-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
}
.agent-files-bar.is-open .agent-files-chevron { transform: rotate(180deg); }
.agent-files-chevron { transition: transform .12s ease; }
.agent-files-stats {
  display: inline-flex;
  gap: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
}
.agent-files-stats .is-add { color: #3fb950; }
.agent-files-stats .is-del { color: #f85149; }
.agent-files-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.agent-files-link {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 2px 0;
  margin: 0;
  font: inherit;
  font-size: 12px;
  color: var(--text, #e6edf3);
  cursor: pointer;
  white-space: nowrap;
}
.agent-files-link:hover {
  color: var(--fg, var(--text));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.agent-files-review {
  font-size: 11px;
  padding: 2px 10px;
}
/* 展开态：列出逐文件 + 行数（点击打开文件） */
.agent-files-list {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.agent-files-bar.is-open .agent-files-list { display: flex; }
.agent-files-list .agent-files-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
}
.agent-files-list .agent-files-row:hover { background: var(--bg-3); }
.agent-files-list .agent-files-row .agent-diff-path { font-weight: 500; }
.agent-files-row-acts {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
}
.agent-todos {
  list-style: none;
  margin: 0 0 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.agent-todo {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}
.agent-todo.is-completed .agent-todo-text {
  text-decoration: line-through;
  opacity: 0.7;
}
.agent-todo.is-cancelled .agent-todo-text { opacity: 0.5; }
.agent-todo-mark { flex-shrink: 0; opacity: 0.85; }
.agent-busy-hint {
  margin: 0 0 6px;
  padding: 0 2px;
  font-size: 11px;
}
.agent-approval-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
}
.agent-approval-pick select {
  max-width: 11em;
  font-size: 12px;
}
.agent-approval-lock {
  display: block;
  padding: 0 8px 6px;
  font-size: 11px;
}
.agent-review-foot-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
}
.agent-review-foot-btn:hover { background: var(--bg-3); }
.agent-review-foot-btn:disabled { opacity: 0.5; cursor: default; }
.agent-diff-card {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2, var(--bg));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.agent-diff-card.is-multi {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.agent-diff-multi-label {
  padding: 4px 10px;
  font-size: 11px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3, var(--bg-2));
}
.agent-diff-file {
  border-bottom: 1px solid var(--line);
  position: relative;
}
.agent-diff-file:last-child {
  border-bottom: none;
}
.agent-diff-filehead {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.agent-diff-file.is-collapsed > .agent-diff-filehead {
  border-bottom: none;
}
.agent-diff-fico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: #fff;
  background: #6e7681;
  flex-shrink: 0;
}
.agent-diff-fico.is-py { background: #3572A5; }
.agent-diff-fico.is-js { background: #f1e05a; color: #1f2328; }
.agent-diff-fico.is-ts { background: #3178c6; }
.agent-diff-fico.is-json { background: #292929; }
.agent-diff-fico.is-md { background: #083fa1; }
.agent-diff-fico.is-yml { background: #cb171e; }
.agent-diff-filelabel {
  display: none;
}
.agent-diff-path {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 500;
  font-size: 12px;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.agent-diff-path:hover {
  color: var(--accent);
  text-decoration: underline;
}
.agent-diff-stats {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}
.agent-diff-stats .is-add { color: #3fb950; }
.agent-diff-stats .is-del { color: #f85149; }
.agent-diff-body {
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  font-family: ui-monospace, Consolas, "SF Mono", monospace;
  line-height: 1.55;
  background: var(--bg, transparent);
}
.agent-diff-file.is-expanded .agent-diff-body {
  max-height: 420px;
}
.agent-diff-peek {
  position: relative;
  max-height: 96px;
  overflow-x: auto;
  overflow-y: hidden;
}
.agent-diff-peek .agent-diff-body {
  max-height: none;
  min-width: max-content;
}
/* Cursor：底部渐隐 + 悬停才显示向下箭头 */
.agent-diff-peek::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg, #0d1117));
  opacity: 0.95;
}
.agent-diff-expand,
.agent-diff-expand-head {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted, #8b949e);
  cursor: pointer;
  padding: 0;
}
.agent-diff-expand-head {
  width: 100%;
  padding: 4px 0 8px;
  font-size: 11px;
}
.agent-diff-expand {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  z-index: 2;
  width: 28px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-3, #21262d);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.agent-diff-file.is-compact:hover .agent-diff-expand,
.agent-diff-file.is-compact:focus-within .agent-diff-expand,
.agent-diff-expand:focus-visible {
  opacity: 1;
  pointer-events: auto;
}
.agent-diff-expand.is-collapse {
  position: sticky;
  bottom: 4px;
  left: 50%;
  margin: 4px auto 6px;
  transform: none;
  display: flex;
  opacity: 0;
  pointer-events: none;
}
.agent-diff-file.is-expanded:hover .agent-diff-expand.is-collapse,
.agent-diff-file.is-expanded:focus-within .agent-diff-expand.is-collapse {
  opacity: 1;
  pointer-events: auto;
}
.agent-diff-expand:hover {
  color: var(--fg, #e6edf3);
  background: var(--bg-4, #30363d);
}
.agent-diff-expand-ico {
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
}
.agent-diff-file.is-expanded .agent-diff-full {
  position: relative;
}
.agent-diff-line {
  display: grid;
  grid-template-columns: 40px 14px 1fr;
  gap: 2px;
  padding: 0 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  border-left: 3px solid transparent;
}
.agent-diff-gutter {
  display: inline-flex;
  gap: 0;
  justify-content: flex-end;
  min-width: 36px;
  padding: 0 6px 0 8px;
  user-select: none;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.agent-diff-ln {
  width: 28px;
  text-align: right;
  color: var(--muted, #6e7681);
  opacity: 0.8;
  font-size: 11px;
}
.agent-diff-mark {
  opacity: 0.7;
  user-select: none;
  text-align: center;
  font-weight: 600;
}
.agent-diff-line.is-add .agent-diff-mark { color: #3fb950; }
.agent-diff-line.is-del .agent-diff-mark { color: #f85149; }
.agent-diff-line.is-add {
  background: rgba(46, 160, 67, 0.14);
  border-left-color: #3fb950;
  color: inherit;
}
.agent-diff-line.is-del {
  background: rgba(248, 81, 73, 0.12);
  border-left-color: #f85149;
  color: inherit;
}
.agent-diff-word.is-add {
  background: rgba(46, 160, 67, 0.35);
  border-radius: 3px;
  padding: 0 2px;
}
.agent-diff-word.is-del {
  background: rgba(248, 81, 73, 0.32);
  border-radius: 3px;
  padding: 0 2px;
}
.agent-diff-line.is-hunk {
  background: rgba(56, 139, 253, 0.10);
  color: #58a6ff;
}
.agent-diff-line.is-meta {
  color: var(--muted);
}
.agent-diff-line.is-ctx {
  color: var(--text);
}
.agent-diff-applied {
  margin-top: 8px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.agent-diff-draft {
  margin-top: 8px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.agent-diff-draft.is-held {
  opacity: 0.72;
}
.agent-diff-draft.is-held .agent-diff-draft-meta {
  color: var(--warn, #e6b84d);
}
.agent-draft-held-reason {
  margin: 0 0 6px 2px;
  font-size: 12px;
  color: var(--warn, #e6b84d);
}
.agent-diff-draft-meta {
  font-size: 11px;
  margin: 0 0 4px 2px;
}
.agent-diff-draft .agent-diff-card,
.agent-diff-applied .agent-diff-card {
  margin-bottom: 0;
}
.agent-draft-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
}
.agent-diff-applied.is-muted {
  opacity: 0.85;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.agent-diff-applied.is-muted .agent-confirm-head {
  margin-bottom: 0;
}
/* 委派审计卡：非文件 diff，弱化展示（2026-09-15） */
.agent-diff-applied.is-delegate {
  opacity: 0.9;
}
.agent-delegate-instr {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-confirm-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.agent-confirm.is-applying {
  opacity: 0.92;
}
.agent-confirm-applying {
  margin: 6px 0 0;
  font-size: 12px;
}
.agent-confirm-actions .btn.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.agent-action-raw { margin-left: auto; flex-shrink: 0; }
.agent-action-raw summary {
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-size: 10px;
}
.agent-action-raw pre {
  margin: 4px 0 0;
  padding: 6px 8px;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 10px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.agent-context {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px 8px;
  align-items: center;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  background: transparent;
}
.agent-context .ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  max-width: 100%;
  min-width: 0;
}
.agent-context .ctx-chip-k {
  opacity: 0.7;
  flex-shrink: 0;
}
.agent-context button.ctx-link {
  border: 0;
  background: transparent;
  color: var(--accent-2, var(--accent));
  padding: 0;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 12em;
}
.agent-context .ctx-sep { opacity: .35; flex-shrink: 0; }

.agent-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.agent-atts:empty { display: none; margin: 0; }
.agent-atts .chip {
  flex: 0 0 auto;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: transparent;
  color: var(--muted);
}

.agent-composer {
  flex-shrink: 0;
  border-top: none;
  padding: 10px 12px 12px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-composer > .agent-files-bar {
  margin: 0;
  flex-shrink: 0;
}
.agent-composer-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--bg-3);
  box-shadow: var(--shadow);
}
.agent-composer-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.agent-composer .agent-input {
  width: 100%;
  min-height: 64px;
  max-height: 160px;
  overflow-y: auto;
  border: 0;
  background: transparent;
  padding: 4px;
  outline: none;
  font: inherit;
  color: inherit;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-composer .agent-input.is-empty:before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}
.agent-composer .composer-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  margin: 1px 2px;
  padding: 1px 6px 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-4, var(--bg-2));
  color: var(--fg, inherit);
  font-size: 12px;
  line-height: 1.4;
  vertical-align: middle;
  user-select: none;
}
.agent-composer .composer-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 12em;
}
.agent-composer .composer-chip-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}
.agent-composer .composer-chip-x:hover { color: var(--danger, #e07070); }
.agent-clarify {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}
.agent-clarify.is-expired {
  opacity: 0.85;
}
.agent-clarify-question {
  font-size: 13px;
  margin-bottom: 8px;
  line-height: 1.45;
}
.agent-clarify-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.agent-clarify-other {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.agent-clarify-input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.agent-clarify-meta {
  font-size: 11px;
}


.agent-composer-box.agent-drag-over {
  outline: 2px dashed var(--accent, #d4a056);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--accent, #d4a056) 6%, var(--bg));
}
.agent-composer .composer-chip[data-kind="image"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 2px;
  max-width: 16em;
}
.agent-composer .composer-chip[data-kind="image"] .composer-chip-thumb {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.agent-attach-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.agent-attach-btn:hover { color: var(--text); }
.agent-attach-btn svg { display: block; }

.agent-composer-foot {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  align-items: center;
}
.agent-composer textarea {
  width: 100%;
  min-height: 64px;
  max-height: 160px;
  resize: vertical;
  border: 0;
  background: transparent;
  padding: 4px;
  outline: none;
}
.agent-composer-foot .grow { flex: 1; min-width: 0; }
.agent-status {
  margin-left: 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.agent-status.is-busy { color: var(--warn, #e6b84d); }
.agent-status.is-job { color: var(--accent, #6cb6ff); }
.agent-job-card {
  margin: 8px 0 4px;
  padding: 8px 10px;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--panel-2, rgba(255,255,255,0.03));
  font-size: 12px;
}
.agent-job-card.is-running {
  border-color: color-mix(in srgb, var(--accent, #6cb6ff) 45%, var(--border, #333));
}
.agent-job-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.agent-job-card-head .grow { flex: 1; min-width: 4px; }
.agent-job-id {
  font-size: 11px;
  opacity: 0.75;
}
.agent-job-elapsed {
  font-size: 11px;
  color: var(--muted);
}
.agent-job-card-detail {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}
.agent-job-card-hint {
  margin-top: 4px;
  font-size: 11px;
}
.agent-thinking-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  color: var(--muted);
  font-size: 12px;
}
.agent-phase-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.agent-approach {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-left: 2px solid var(--accent-2, #6ea8ff);
  background: color-mix(in srgb, var(--accent-2, #6ea8ff) 12%, transparent);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  border-radius: 0 4px 4px 0;
}
.agent-phase-status .agent-phase-label {
  color: var(--warn, #e6b84d);
  font-weight: 500;
}
.agent-phase-status[data-phase="tool"] .agent-phase-label,
.agent-phase-status[data-phase="waiting_subagent"] .agent-phase-label {
  color: var(--accent, #d4a056);
}
.agent-phase-status[data-phase="responding"] .agent-phase-label {
  color: var(--accent-2, #6ea8ff);
}
.agent-phase-status[data-phase="reconnecting"] .agent-phase-label {
  color: var(--warn, #e6b84d);
}
/* Cursor：底部弹性留白，滚到底时最新输出落在栏中部偏上，仍可自由滚动 */
.agent-log-spacer {
  flex-shrink: 0;
  width: 100%;
  pointer-events: none;
  min-height: 0;
}
.agent-thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn, #e6b84d);
  animation: agent-pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}
.agent-think {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  font-size: 13px;
  color: var(--muted);
  padding: 2px 10px;
}
.agent-think > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 0;
  list-style: none;
  user-select: none;
}
.agent-think > summary::-webkit-details-marker { display: none; }
.agent-think > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted, #66778c);
  flex-shrink: 0;
  transition: transform .12s ease;
  transform: rotate(-90deg);
  opacity: 0.7;
}
.agent-think[open] > summary::before {
  transform: rotate(0deg);
}
.agent-think-label {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}
.agent-think-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--muted);
}
.agent-think-body {
  padding: 4px 0 8px 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 280px;
  overflow: auto;
  color: var(--muted);
  opacity: 0.9;
  font-size: 12px;
}
.agent-think.is-streaming > summary { color: var(--warn, #e6b84d); }
.msg.is-streaming .msg-body { opacity: 0.92; }

/* Cursor 风格：子 Agent 任务卡（标题旁模型 + Waiting for subagent） */
.agent-subagents {
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-subagent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  font-family: inherit;
}
button.agent-subagent:hover {
  border-color: var(--border, #3a3a3a);
  background: var(--panel-2, rgba(255, 255, 255, 0.03));
}
.agent-subagent-live {
  margin-top: 4px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.agent-subagent-dialog {
  width: min(560px, 92vw);
  max-height: min(70vh, 640px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-3);
  color: var(--text);
  color-scheme: light;
  padding: 0;
  box-shadow: var(--shadow);
}
.agent-subagent-dialog::backdrop {
  background: rgba(26, 36, 51, 0.28);
}
.agent-subagent-dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  margin: 0;
  background: var(--bg-3);
  color: var(--text);
}
.agent-subagent-dialog-head strong { flex: 1; font-size: 13px; color: var(--text); }
.agent-subagent-dialog-body {
  margin: 0;
  padding: 12px;
  max-height: calc(70vh - 52px);
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-2);
  color: var(--text);
}
.agent-subagent-ico {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: -1px;
}
.agent-subagent.is-running .agent-subagent-ico {
  color: var(--accent, #d4a056);
}
.agent-subagent-body { min-width: 0; flex: 1; }
.agent-subagent-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.agent-subagent-title {
  font-weight: 500;
  color: var(--text);
}
.agent-subagent-model {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.agent-subagent-status {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.agent-subagent.is-failed .agent-subagent-status {
  color: var(--danger, #e05a5a);
}
.agent-waiting-subagent {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

@keyframes agent-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}
.agent-composer textarea:disabled,
.agent-composer .agent-input[contenteditable="false"],
.agent-composer .btn:disabled,
.agent-head .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.agent-mention-wrap { position: relative; }
.agent-mention {
  position: absolute;
  left: 0; right: 0; bottom: 100%;
  margin-bottom: 4px;
  max-height: 220px;
  overflow: auto;
  z-index: 20;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  box-shadow: var(--shadow);
  padding: 4px;
}
.agent-mention.hidden { display: none; }
.agent-mention-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.agent-mention-item:hover,
.agent-mention-item.is-current {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-4));
}
.agent-mention-item strong {
  color: var(--text);
  font-weight: 600;
}
.agent-mention-item .muted {
  font-size: 11px;
  color: var(--muted);
  opacity: 1;
}

.agent-path { color: var(--accent); text-decoration: underline; }
.agent-hitl {
  border-top: 1px solid var(--warn);
  background: #2a2414;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.agent-hitl-text { font-size: 12px; color: var(--fg, #e8e6e3); }
.agent-hitl-plan { font-size: 11px; line-height: 1.4; }
.agent-hitl-plan.muted { opacity: 0.75; }
.agent-hitl-plan.warn {
  color: var(--warn);
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.agent-hitl-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.status-right { display: inline-flex; align-items: center; gap: 8px; }
.status-hitl { font-size: 11px; padding: 2px 8px; }
.tl { display: flex; gap: 8px; padding: 10px; align-items: stretch; min-width: min-content; }
.tl-shot { min-width: 88px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer; font-size: 11px; }
.tl-shot.selected { outline: 1px solid var(--accent); }
.log { font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: pre-wrap; color: #c8c4bb; }
.api-down { background: #4a1c1c; color: #ffd0d0; }

.welcome { max-width: 640px; margin: 8vh auto; padding: 24px; }
.welcome h1 { font-size: 28px; margin: 0 0 8px; }
.welcome .row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist-scroll {
  max-height: min(42vh, 360px);
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  overscroll-behavior: contain;
}
.plist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.plist-item:last-child { border-bottom: none; }
.plist-body { flex: 1; min-width: 0; }
.plist-body .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plist-del {
  flex-shrink: 0;
  font-size: 11px;
  padding: 4px 10px;
  opacity: 0.7;
}
.plist-item:hover .plist-del { opacity: 1; }
.picker-list { max-height: min(42vh, 360px); overflow: auto; margin: 8px 0 0; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--bg); }
.picker-list .picker-item { padding: 10px 4px; }
.picker-list .picker-item:hover, .picker-list .picker-item:focus { background: var(--bg-4); outline: none; }
.picker-list .picker-item.is-current { border-left: 2px solid var(--accent, #6ea8fe); padding-left: 8px; }
.open-picker-dialog { width: min(560px, 92vw); }

.modal { position: fixed; inset: 0; background: rgba(26, 36, 51, 0.28); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 40; }
.modal.hidden, .ctx.hidden, .hidden { display: none !important; }
.dialog { width: min(520px, 92vw); background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.studio-confirm-dialog {
  width: min(440px, 92vw);
  background: #fff;
  color: #1f2328;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 20px 22px 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
}
.studio-confirm-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  color: #1f2328;
}
.studio-confirm-body {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.45;
  color: #656d76;
  white-space: pre-wrap;
}
.studio-confirm-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.studio-confirm-dontask {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #656d76;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1;
}
.studio-confirm-dontask input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: #1f2328;
}
.studio-confirm-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.studio-confirm-cancel {
  border: none;
  background: transparent;
  color: #424a53;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 4px;
}
.studio-confirm-cancel:hover { color: #1f2328; }
.studio-confirm-ok {
  min-width: 108px;
}

.modal.modal-prompt-edit {
  display: block;
  background: rgba(12, 16, 22, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.canvas-prompt-edit-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 94vw);
  max-height: min(84vh, 760px);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-2, #161b22);
  color: var(--fg, #e6edf3);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 64px rgba(0, 0, 0, 0.45);
  z-index: 41;
}
.canvas-prompt-edit-dialog.is-dragging {
  opacity: 0.97;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 28px 72px rgba(0, 0, 0, 0.55);
  user-select: none;
}
.canvas-prompt-edit-drag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  cursor: grab;
  touch-action: none;
  user-select: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
}
.canvas-prompt-edit-dialog.is-dragging .canvas-prompt-edit-drag {
  cursor: grabbing;
}
.canvas-prompt-edit-grip {
  flex: 0 0 auto;
  width: 14px;
  height: 18px;
  border-radius: 3px;
  background:
    radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 6px 6px,
    radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 6px 0 / 6px 6px;
  background-repeat: repeat-y;
  opacity: 0.35;
}
.canvas-prompt-edit-heading {
  flex: 1;
  min-width: 0;
}
.canvas-prompt-edit-heading h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  color: inherit;
}
.canvas-prompt-edit-sub {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted, #8b949e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.canvas-prompt-edit-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #8b949e);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.canvas-prompt-edit-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}
.canvas-prompt-edit-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
  min-height: 0;
  flex: 1;
}
.canvas-prompt-edit-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted, #8b949e);
}
.canvas-prompt-edit-input {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 220px;
  max-height: min(52vh, 480px);
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 10px;
  background: var(--bg-1, #0d1117);
  color: inherit;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}
.canvas-prompt-edit-input.is-single {
  flex: 0 0 auto;
  min-height: 0;
  height: 38px;
  max-height: none;
  resize: none;
}
.canvas-prompt-edit-input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent, #6ea8fe) 45%, transparent);
  border-color: var(--accent, #6ea8fe);
}
.canvas-prompt-edit-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}
.msg.user.is-editing {
  background: transparent;
  border: none;
  padding: 0;
  outline: none;
}
.msg.user.is-editing .msg-user-row {
  display: block;
}
.msg-inline-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg-2, transparent);
}
.msg-inline-edit:focus-within {
  border-color: var(--accent);
}
.msg-inline-edit-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.msg-inline-edit-thumb-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-3);
}
.msg-inline-edit-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg-inline-edit-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.msg-inline-edit-ta {
  width: 100%;
  min-height: 72px;
  max-height: 240px;
  resize: vertical;
  font: inherit;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
  outline: none;
}
.msg-inline-edit-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.msg-inline-edit-foot .grow {
  flex: 1;
  min-width: 8px;
}
.msg-inline-edit-foot .agent-mode-menu,
.msg-inline-edit-foot .agent-model-menu {
  bottom: calc(100% + 6px);
  top: auto;
}
.msg.is-editing {
  outline: none;
}
.dialog label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.dialog input, .dialog select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.ctx {
  position: fixed;
  z-index: 100;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 180px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px;
  box-shadow: var(--shadow);
}
.ctx button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 8px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.ctx button:hover { background: var(--accent-soft); color: var(--accent); }
.ctx-sep { height: 1px; margin: 4px 0; background: var(--line); border: 0; }
.ctx button:disabled { opacity: 0.45; pointer-events: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.idle { background: var(--muted); }

/* 设置页：Cursor 式左右分栏（左导航固定列 + 右内容区） */
.settings-form.preview,
.preview.settings-form {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--bg);
}
.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px 10px 20px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  box-sizing: border-box;
}
.settings-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
  min-width: 0;
}
.settings-profile-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-4);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
}
.settings-profile-meta {
  min-width: 0;
  flex: 1 1 auto;
}
.settings-profile-email {
  font-size: 12px;
  font-weight: 550;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-profile-plan {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.3;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-sizing: border-box;
}
.settings-nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
}
.settings-nav-item:hover {
  color: var(--text);
  background: var(--bg-3);
}
.settings-nav-item.active {
  color: var(--text);
  background: var(--bg-3);
  font-weight: 600;
}
.settings-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px 28px 36px;
  background: var(--bg);
  box-sizing: border-box;
  container-type: inline-size;
  container-name: settings-main;
}
.settings-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent-2, #6ea8ff) 35%, var(--line));
  background: color-mix(in srgb, var(--accent-2, #6ea8ff) 12%, var(--bg-2));
  font-size: 12px;
  line-height: 1.45;
  margin: 0 0 4px;
}
.settings-banner-body {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
}
.settings-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}
.settings-section-label {
  margin: 10px 0 8px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.settings-panel > .settings-section-label:first-of-type,
.settings-panel > h2 + .settings-section-label {
  margin-top: 0;
}
.settings-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  overflow: hidden;
}
.settings-card + .settings-card {
  margin-top: 0;
}
.settings-card-title {
  padding: 12px 16px 0;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.settings-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.settings-row:last-child {
  border-bottom: none;
}
.settings-row-text {
  flex: 1 1 auto;
  min-width: 0;
}
.settings-row > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}
.settings-row-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  line-height: 1.35;
}
.settings-row-desc {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  max-width: 42rem;
}
.settings-row-control {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(280px, 42%);
}
.settings-row-control > select,
.settings-row-control > input:not([type="checkbox"]) {
  width: auto;
  min-width: 7.5rem;
  max-width: 100%;
}
.settings-open-btn {
  white-space: nowrap;
}
.settings-channel-toggle {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
}
.settings-channel-toggle .btn {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.settings-channel-toggle .btn.primary {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}
.settings-toggle {
  appearance: none;
  position: relative;
  width: 40px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--bg-4);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.settings-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
.settings-toggle.is-on {
  background: var(--ok, #3dcc8a);
}
.settings-toggle.is-on::after {
  transform: translateX(18px);
}
.settings-logout-btn {
  align-self: flex-start;
  margin-top: 8px;
}
.usage-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 4px;
}
@container settings-main (max-width: 560px) {
  .usage-plan-grid {
    grid-template-columns: 1fr;
  }
}
.usage-plan-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  min-width: 0;
}
.usage-plan-card.is-upgrade {
  border-color: color-mix(in srgb, var(--accent-2, #6ea8ff) 45%, var(--line));
  background: color-mix(in srgb, var(--accent-2, #6ea8ff) 12%, var(--bg-2));
}
.usage-plan-card.is-muted {
  opacity: 0.92;
}
.usage-plan-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.usage-plan-title {
  font-size: 16px;
  line-height: 1.3;
  color: var(--text);
}
.usage-plan-price {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.usage-plan-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  flex: 1 1 auto;
}
.usage-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.usage-meters-card {
  padding: 4px 0;
}
.usage-meters-card .usage-meter {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.usage-meters-card .usage-meter:last-child {
  border-bottom: none;
}
.usage-meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.usage-meter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}
.usage-meter-pct {
  flex-shrink: 0;
  font-size: 12px;
}
.usage-meter-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-4);
  overflow: hidden;
}
.usage-meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2, #6ea8ff);
  min-width: 0;
  transition: width 0.2s ease;
}
.usage-meter-caption {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
}
.settings-login-card {
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}
.settings-media-table {
  margin: 8px 12px 12px;
  width: calc(100% - 24px);
}
.settings-media-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
.settings-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-width: 0;
  max-width: 920px;
}
.settings-panel > h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.settings-panel > h3 {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.settings-panel > h2 + h3 {
  margin-top: 0;
}
.settings-panel > p.muted {
  margin: 0;
}
.settings-panel > .row,
.settings-panel > .settings-actions {
  margin-top: 4px;
}
.settings-panel > label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.settings-panel > label.check {
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
}
.settings-form input:not([type="checkbox"]):not([type="radio"]),
.settings-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: #111111;
  -webkit-text-fill-color: #111111;
  caret-color: #111111;
  color-scheme: light;
  box-sizing: border-box;
}
.settings-form select option,
.settings-form select optgroup {
  background: #ffffff;
  color: #111111;
}
.settings-form input[type="checkbox"],
.settings-form input[type="radio"] {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  max-width: 1rem;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
  background: transparent;
  border: none;
  border-radius: 0;
  -webkit-text-fill-color: unset;
}
.settings-form .settings-layout-toggles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px 16px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  box-sizing: border-box;
}
.settings-form .settings-layout-toggles > label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0;
  padding: 6px 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  width: auto;
  max-width: 100%;
  min-height: 0;
}
@container settings-main (min-width: 420px) {
  .settings-form .settings-layout-toggles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.settings-form input::placeholder {
  color: #6b7280;
  -webkit-text-fill-color: #6b7280;
  opacity: 1;
}
.settings-form input:-webkit-autofill,
.settings-form input:-webkit-autofill:hover,
.settings-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: #111111;
  box-shadow: 0 0 0 1000px #ffffff inset;
}
.settings-form fieldset.slot {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0;
  padding: 12px 14px 14px;
  background: var(--bg-2);
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.settings-form fieldset.slot > legend {
  padding: 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.settings-form fieldset.slot > .muted { margin: 0 0 8px; font-size: 12px; }
.settings-form fieldset.slot > label { margin: 4px 0 2px; }

@container settings-main (min-width: 560px) {
  .settings-panel[data-settings-panel="models"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 12px;
  }
  .settings-panel[data-settings-panel="models"] > h2,
  .settings-panel[data-settings-panel="models"] > h3,
  .settings-panel[data-settings-panel="models"] > p,
  .settings-panel[data-settings-panel="models"] > table,
  .settings-panel[data-settings-panel="models"] > .row,
  .settings-panel[data-settings-panel="models"] > label,
  .settings-panel[data-settings-panel="models"] > select,
  .settings-panel[data-settings-panel="models"] > input,
  .settings-panel[data-settings-panel="models"] > .settings-layout-toggles,
  .settings-panel[data-settings-panel="models"] > .settings-card,
  .settings-panel[data-settings-panel="models"] > .settings-actions {
    grid-column: 1 / -1;
  }
  .settings-panel[data-settings-panel="models"] > fieldset.slot {
    grid-column: span 2;
  }
  .settings-panel[data-settings-panel="models"] > fieldset.slot.slot-pick {
    grid-column: span 1;
  }
  .settings-panel[data-settings-panel="models"] > fieldset.slot.slot-catalog,
  .settings-panel[data-settings-panel="models"] > fieldset.slot.slot-global {
    grid-column: 1 / -1;
  }
}

@container settings-main (min-width: 720px) {
  .settings-form fieldset.slot {
    grid-template-columns: minmax(120px, 22%) minmax(0, 1fr);
    column-gap: 12px;
    align-items: start;
  }
  .settings-form fieldset.slot > legend { grid-column: 1 / -1; }
  .settings-form fieldset.slot > label { grid-column: 1; margin-top: 8px; }
  .settings-form fieldset.slot > input,
  .settings-form fieldset.slot > select { grid-column: 2; }
  .settings-form fieldset.slot.slot-catalog {
    display: block;
  }
}

.settings-form fieldset.slot.slot-catalog {
  display: block;
}
#model-catalog th:nth-child(1),
#model-catalog td:nth-child(1) { width: 11rem; white-space: nowrap; }
#model-catalog th:nth-child(5),
#model-catalog td:nth-child(5) { width: 4.5rem; }
#model-catalog select,
#model-catalog input { width: 100%; min-width: 0; }
.settings-form table.grid input,
.settings-form table.grid select {
  background: #ffffff;
  color: #111111;
  -webkit-text-fill-color: #111111;
  border: 1px solid var(--line);
  color-scheme: light;
}

/* 表单内表格：永远占满当前列宽，不超出 */
.settings-form table.grid { width: 100%; max-width: 100%; table-layout: auto; }
.settings-form table.grid td { word-break: break-word; }

/* 顶部行动作条：按钮自然换行，不挤 */
.settings-form .row,
.settings-form .settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-form .row .btn,
.settings-form .settings-actions .btn { flex: 0 0 auto; }

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  cursor: help;
  flex-shrink: 0;
}
.help-q {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}
.help-tip:hover .help-q,
.help-tip:focus .help-q,
.help-tip:focus-within .help-q {
  border-color: var(--accent);
  color: var(--accent);
}
.help-bubble {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  bottom: auto;
  right: auto;
  transform: translateY(-50%);
  width: max-content;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #1a1d24;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease, visibility .12s ease;
  z-index: 40;
}
.help-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -6px;
  right: auto;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1a1d24;
}
.help-tip:hover .help-bubble,
.help-tip:focus .help-bubble,
.help-tip:focus-within .help-bubble {
  opacity: 1;
  visibility: visible;
}
.settings-form label .help-tip,
.settings-form legend .help-tip,
.settings-form h2 .help-tip,
.settings-form h3 .help-tip {
  margin-left: 6px;
}
.settings-panel > label:not(.check) {
  display: block;
}
.settings-form label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}

.dialog textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  resize: vertical;
  min-height: 120px;
}
.style-family-combo {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(0, 1.4fr);
  gap: 8px;
  align-items: stretch;
}
.style-family-combo select,
.style-family-combo input {
  width: 100%;
  margin: 0;
}
@media (max-width: 520px) {
  .style-family-combo { grid-template-columns: 1fr; }
}
.dialog label { display: block; margin-top: 10px; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.dialog input, .dialog select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.dialog ul { margin: 8px 0; padding-left: 1.2em; }

.git-commit-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.git-panel { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.versions-panel { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.versions-panel .versions-item { padding: 6px 0; border-bottom: 1px solid var(--border, #3333); }
.versions-panel #version-msg { width: 100%; box-sizing: border-box; }
.git-head-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.git-branch {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.git-group { margin-top: 8px; }
.git-group-title {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.git-field-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.git-field-row .filter,
.git-field-row select {
  flex: 1 1 auto;
  min-width: 0;
}
.git-field-row .btn { flex: 0 0 auto; }
.git-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border-radius: 6px;
  cursor: pointer;
}
.git-file:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.git-badge {
  flex: 0 0 18px;
  width: 18px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
}
.git-badge-modified, .git-badge-changed { color: #d7a33a; }
.git-badge-added { color: #6bbf6b; }
.git-badge-deleted { color: #e06c75; }
.git-badge-untracked { color: #61afef; }
.git-badge-renamed { color: #c678dd; }
.git-badge-conflict { color: #ff6b6b; }
.git-file-meta { min-width: 0; flex: 1; overflow: hidden; }
.git-file-meta strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.git-file-acts {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
  opacity: 0.85;
}
.git-file-acts .btn { padding: 2px 6px; font-size: 11px; }
.git-diff-view {
  overflow: auto;
  min-height: 0;
  padding: 8px 10px;
}
.git-diff-view .agent-diff-body { margin-top: 6px; }
.git-check {
  flex-shrink: 0;
  margin-top: 2px;
}
.git-diff {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}
.term-panel .code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}
.status-git {
  padding: 0 6px;
  font-size: 11px;
  vertical-align: baseline;
}


/* —— bible / storyboard card deck —— */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px;
  min-height: 0;
}
.card-deck {
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.card-deck .card-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.card-deck .entity-card {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.card-deck .entity-card.is-active,
.card-deck .entity-card:not([hidden]) {
  display: flex;
}
.card-deck .entity-card[hidden] {
  display: none !important;
}
.card-switcher {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.entity-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-3);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.bible-card.entity-card {
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
  background: var(--bg-3);
  box-shadow: none;
  gap: 14px;
  padding: 14px 16px;
}
.entity-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.bible-card.entity-card.is-active {
  border-color: color-mix(in srgb, var(--line) 88%, var(--fg));
  box-shadow: none;
}
.entity-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
}
.entity-card-title {
  font-size: 14px;
  letter-spacing: 0.02em;
}
.entity-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.entity-card-actions .btn { width: auto; }
/* Bible 卡（角色 / 场景 / 道具）：顶栏按钮胶囊简约风 */
.bible-card .entity-card-actions {
  gap: 4px;
  align-items: center;
}
.bible-card .entity-card-actions .btn {
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  border-radius: 999px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--line) 92%, var(--fg));
  box-shadow: none;
  color: var(--fg);
}
.bible-card .entity-card-actions .btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  border-color: color-mix(in srgb, var(--fg) 24%, var(--line));
}
.bible-card .entity-card-actions .btn.primary {
  background: color-mix(in srgb, var(--fg) 90%, #000);
  border-color: transparent;
  color: #fff;
  box-shadow: none;
}
.bible-card .entity-card-actions .btn.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--fg) 76%, #000);
}
.bible-card .entity-card-actions .btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--bad) 40%, var(--line));
  color: var(--bad);
}
.bible-card .entity-card-actions .btn.danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bad) 8%, transparent);
}
.bible-card.char-profile .char-aux-btn {
  width: auto;
  flex: 0 0 auto;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.3;
  border-radius: 999px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--fg) 22%, var(--line));
  color: var(--fg);
  box-shadow: none;
}
.bible-card.char-profile .char-aux-btn.primary {
  background: transparent;
  border-color: color-mix(in srgb, var(--fg) 28%, var(--line));
  color: var(--fg);
  box-shadow: none;
}
.bible-card.char-profile .char-aux-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  border-color: color-mix(in srgb, var(--fg) 40%, var(--line));
}
.bible-card.char-profile .char-aux-btn:disabled {
  opacity: 0.4;
}
.entity-card-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}
.entity-card-body .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.entity-card-body .field > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.entity-card-body .field input,
.entity-card-body .field textarea,
.entity-card-body .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.entity-card-body .field textarea {
  min-height: 72px;
  resize: vertical;
}
.entity-card-body .field-wide {
  grid-column: 1 / -1;
}
.bible-card .entity-card-body.bible-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: unset;
  grid-template-columns: unset;
}

/* 角色资料卡：主区（立绘 + 提示词）· 衍生 / 备忘折叠 */
.bible-card.char-profile .entity-card-body.char-profile-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}
.char-profile-main {
  display: grid;
  grid-template-columns: minmax(200px, 0.72fr) minmax(280px, 1.28fr);
  gap: 12px 16px;
  align-items: start;
}
.char-profile-viz-primary .char-viz-media {
  aspect-ratio: 9 / 16;
  max-height: 360px;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  background: var(--bg-4);
  box-shadow: var(--shadow);
}
.char-profile-viz-primary .char-viz-media img {
  max-height: 360px;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  clip-path: inset(0 round 16px);
}
.char-profile-prompt {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.char-profile-prompt .char-attr-compact.bible-meta-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}
.char-profile-prompt .char-attr-span {
  grid-column: 1 / -1;
}
.media-prompt-block.is-primary .char-block-field textarea {
  min-height: 140px;
  font-size: 13.5px;
  line-height: 1.55;
}
.char-more {
  position: relative;
}
.char-more > summary {
  list-style: none;
  cursor: pointer;
}
.char-more > summary::-webkit-details-marker {
  display: none;
}
.char-more-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel, var(--bg));
  box-shadow: 0 8px 20px color-mix(in srgb, #000 18%, transparent);
}
.char-fold {
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  overflow: hidden;
}
.char-fold-sum {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  user-select: none;
}
.char-fold-sum::-webkit-details-marker {
  display: none;
}
.char-fold-sum::before {
  content: "▸";
  color: var(--muted);
  font-weight: 400;
  width: 1em;
}
.char-fold[open] > .char-fold-sum::before {
  content: "▾";
}
.char-fold-body {
  padding: 0 12px 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding-top: 12px;
}
.char-fold-body.char-profile-viz .char-viz-top {
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
}
.char-fold-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.char-profile-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
}
.char-profile-viz {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.char-viz-top {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.75fr) minmax(0, 1.15fr);
  gap: 10px;
  align-items: stretch;
}
.char-viz {
  margin: 0;
  position: relative;
  border: none;
  border-radius: 14px;
  background: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.char-viz.is-wide,
.char-turn-panel {
  width: 100%;
}
.char-turn-panel {
  background: transparent;
}
.char-viz-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: 0.02em;
  line-height: 1.35;
  color: #fff;
  background: color-mix(in srgb, var(--fg) 92%, #000);
  border-radius: 999px;
  pointer-events: none;
}
.char-viz-media {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 160px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--bg-4);
  cursor: zoom-in;
  text-align: center;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow);
}
.char-viz-media img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 280px;
  margin: 0 auto;
  object-fit: cover;
  border-radius: 0;
  clip-path: inset(0 round 16px);
}
.char-profile-viz-primary .char-viz-media img {
  max-height: 360px;
}
.char-viz.is-wide .char-viz-media img,
.char-turn-panel .char-turn-cell img {
  max-height: 320px;
}
.char-viz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 140px;
  margin: 0;
  padding: 28px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.4;
  word-break: break-all;
  background: var(--bg-4);
}
.char-aux-btn {
  width: auto;
  flex: 0 0 auto;
}
.char-viz-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px 10px;
}
.mounted-compose-dialog {
  width: min(560px, 94vw);
}
.mounted-compose-props {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  margin: 10px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.mounted-compose-prop {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
}
.mounted-compose-prop.is-missing {
  opacity: 0.55;
}
.mounted-compose-dialog textarea {
  width: 100%;
  min-height: 110px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: inherit;
  font: inherit;
}
.char-aux-foot {
  display: flex;
  justify-content: center;
  padding: 0 10px 12px;
}
button.char-turn-cell.is-empty {
  cursor: pointer;
  border: 1px dashed color-mix(in srgb, var(--line) 80%, var(--muted));
  background: transparent;
}
button.char-turn-cell.is-empty:hover {
  border-color: color-mix(in srgb, var(--fg) 35%, var(--line));
  color: var(--fg);
}
.char-viz.is-wide .char-viz-empty,
.char-turn-panel .char-viz-empty {
  min-height: 160px;
}
.char-viz-empty.is-sm,
.char-viz.is-compact .char-viz-empty {
  min-height: 120px;
  padding: 24px 10px 12px;
  font-size: 11px;
}
.char-expr-panel,
.char-turn-panel {
  width: 100%;
}
.char-expr-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  flex: 1 1 auto;
}
.char-expr-cell,
.char-turn-cell {
  aspect-ratio: 1;
  border: none;
  border-radius: 6px;
  background: transparent;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
}
button.char-expr-cell,
button.char-turn-cell {
  cursor: pointer;
}
.char-expr-cell img,
.char-turn-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.char-expr-cell.is-empty,
.char-turn-cell.is-empty {
  opacity: 0.55;
  background: color-mix(in srgb, var(--bg) 70%, var(--line));
  border: 1px dashed color-mix(in srgb, var(--line) 80%, var(--muted));
}
.char-expr-lab {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 10px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 2px #000;
  pointer-events: none;
}
.char-expr-cell.is-empty .char-expr-lab {
  color: var(--muted);
  text-shadow: none;
}
.char-expr-tip {
  margin: 0 8px 4px;
  font-size: 11px;
}
.expression-slot-dialog {
  width: min(480px, 94vw);
}
.expression-slot-dialog textarea {
  width: 100%;
  min-height: 96px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: inherit;
  font: inherit;
}
.char-expr-miss {
  color: var(--muted);
  font-size: 11px;
}
.char-turn-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 36px 12px 14px;
  flex: 1 1 auto;
  min-height: 180px;
  align-items: end;
}
.char-turn-cell {
  aspect-ratio: 3 / 4;
  position: relative;
  background: transparent;
}
.char-turn-cell img {
  object-fit: contain;
}
.char-turn-lab {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: transparent;
  padding: 0;
  border-radius: 0;
  opacity: 0.7;
}
.char-profile-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.char-profile-meta .char-attr-grid.bible-meta-grid,
.char-profile-prompt .char-attr-grid.bible-meta-grid,
.char-look-attrs.bible-meta-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}
.char-profile-meta .char-attr-span,
.char-profile-prompt .char-attr-span {
  grid-column: 1 / -1;
}
.char-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.char-block-h {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
}
/* 角色卡 meta / 人物属性：标签与控件同一行 */
.char-profile-meta .char-attr-grid.bible-meta-grid .field,
.char-profile-prompt .char-attr-grid.bible-meta-grid .field,
.char-look-attrs.bible-meta-grid .field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.char-profile-meta .char-attr-grid.bible-meta-grid .field > span,
.char-profile-prompt .char-attr-grid.bible-meta-grid .field > span,
.char-look-attrs.bible-meta-grid .field > span {
  flex: 0 0 2.75em;
  white-space: nowrap;
  color: var(--muted);
}
.char-profile-meta .char-attr-grid.bible-meta-grid .field input,
.char-profile-meta .char-attr-grid.bible-meta-grid .field select,
.char-profile-prompt .char-attr-grid.bible-meta-grid .field input,
.char-profile-prompt .char-attr-grid.bible-meta-grid .field select,
.char-look-attrs.bible-meta-grid .field input,
.char-look-attrs.bible-meta-grid .field select {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  box-shadow: none;
  color: var(--fg);
}
.char-profile-meta .char-attr-grid.bible-meta-grid .field input:focus,
.char-profile-meta .char-attr-grid.bible-meta-grid .field select:focus,
.char-profile-prompt .char-attr-grid.bible-meta-grid .field input:focus,
.char-profile-prompt .char-attr-grid.bible-meta-grid .field select:focus,
.char-look-attrs.bible-meta-grid .field input:focus,
.char-look-attrs.bible-meta-grid .field select:focus {
  outline: none;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.char-look-attrs .char-art-readonly,
.char-look-attrs input:disabled {
  opacity: 0.85;
  cursor: default;
  background: transparent;
}
.char-block-field {
  margin: 0;
}
.char-profile-meta .char-block-field textarea,
.char-block-field textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  color: var(--fg);
  font: inherit;
  line-height: 1.55;
  box-shadow: none;
}
.char-profile-meta .char-block-field textarea:focus,
.char-block-field textarea:focus {
  outline: none;
  border: none;
  box-shadow: none;
}
.char-profile-meta .char-block-field textarea::placeholder,
.char-block-field textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}
.media-prompt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 6px;
}
.media-prompt-badge {
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}
.media-prompt-checklist-dialog {
  width: min(560px, 94vw);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-prompt-checklist-dialog > h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.media-prompt-checklist-dialog > .muted {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.media-prompt-checklist-body {
  flex: 1 1 auto;
  max-height: min(56vh, 420px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 14px 16px;
  margin: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.char-path-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  font-size: 12px;
}
.char-path-row .mono {
  word-break: break-all;
}
@media (max-width: 1080px) {
  .char-profile-main {
    grid-template-columns: 1fr;
  }
  .char-viz-top,
  .char-fold-body.char-profile-viz .char-viz-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .char-viz-top,
  .char-fold-body.char-profile-viz .char-viz-top {
    grid-template-columns: 1fr;
  }
}
.bible-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  flex: 0 0 auto;
}
.bible-meta-grid .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.bible-meta-grid .field > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.bible-meta-grid .field input,
.bible-meta-grid .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
/* Bible 场景 / 道具卡：与角色卡同一套无框字段 */
.bible-card .bible-meta-grid .field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.bible-card .bible-meta-grid .field > span {
  flex: 0 0 4em;
  white-space: nowrap;
}
.bible-card .bible-meta-grid .field input,
.bible-card .bible-meta-grid .field select {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  box-shadow: none;
  color: var(--fg);
}
.bible-card .bible-meta-grid .field input:focus,
.bible-card .bible-meta-grid .field select:focus {
  outline: none;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.bible-fill-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
}
.bible-fill-stack .field-fill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
  min-height: 0;
}
.bible-fill-stack .field-fill > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}
.bible-fill-stack .field-fill textarea {
  flex: 0 0 auto;
  width: 100%;
  min-height: 88px;
  height: auto;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.bible-card .bible-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bible-card .bible-block-h {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
}
.bible-card .bible-block-field {
  margin: 0;
}
.bible-card .bible-fill-stack .field-fill > span,
.bible-card .bible-block-field > span:first-child {
  display: none;
}
.bible-card .bible-fill-stack .field-fill textarea,
.bible-card .bible-block-field textarea,
.bible-card .entity-card-body .bible-block-field textarea {
  min-height: 72px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  color: var(--fg);
  font: inherit;
  line-height: 1.55;
}
.bible-card .bible-fill-stack .field-fill textarea:focus,
.bible-card .bible-block-field textarea:focus,
.bible-card .entity-card-body .bible-block-field textarea:focus {
  outline: none;
  border: none;
  box-shadow: none;
}
.bible-card .related-locs-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-ref-chip {
  align-items: center;
  gap: 6px;
}
.card-ref-thumb {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
  background: var(--bg-2);
}
.bible-card .related-locs-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
}
.bible-card .related-locs-label.muted {
  color: var(--fg);
}
.bible-rules-sec h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg);
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  margin: 0 0 12px;
}
.bible-rules-sec .bible-rules {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  font: inherit;
  line-height: 1.55;
  color: var(--fg);
}
.bible-rules-sec .bible-rules:focus {
  outline: none;
}
.bible-section .card-list.card-deck .card-stage {
  overflow: hidden;
}
.bible-section .card-list.card-deck .entity-card.is-active {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.entity-card-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.card-id-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.card-id-chip {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.card-id-chip:hover {
  border-color: var(--accent-2);
  color: var(--text);
}
.card-id-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
}
.card-id-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}
.card-meta-chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.board-cards .board-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.board-cards .board-actions .btn {
  width: auto;
  white-space: nowrap;
}
.shot-card {
  gap: 12px;
}
.shot-head-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.shot-head-meta {
  font-size: 12px;
  white-space: nowrap;
}
.shot-meta-row {
  display: grid;
  grid-template-columns: 72px 64px minmax(148px, 1fr) minmax(132px, 1fr) minmax(140px, 1.4fr);
  gap: 8px 10px;
  align-items: end;
}
.shot-meta-row .field,
.shot-main .field,
.entity-card-body .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.shot-meta-row .field > span,
.shot-main .field > span,
.entity-card-body .field > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.shot-meta-row .field input:not([type="checkbox"]):not([type="radio"]),
.shot-meta-row .field select,
.shot-main .field input:not([type="checkbox"]):not([type="radio"]),
.shot-main .field textarea,
.shot-main .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.cam-combo {
  position: relative;
  min-width: 0;
}
.cam-combo input {
  padding-right: 26px;
}
.cam-combo-caret {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 24px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.cam-combo-caret::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}
.cam-combo-menu {
  z-index: 80;
  max-height: min(280px, 50vh);
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 4px;
  box-sizing: border-box;
}
.cam-combo-opt {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.cam-combo-opt:hover,
.cam-combo-opt.is-on {
  background: var(--bg-2, color-mix(in srgb, var(--accent) 12%, var(--bg)));
}
.shot-main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(200px, 0.95fr);
  grid-template-rows: minmax(420px, 1fr);
  gap: 14px;
  flex: 1 1 auto;
  min-height: 420px;
  align-items: stretch;
}
.shot-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 420px;
  min-width: 0;
}
.shot-copy .field > span {
  flex: 0 0 auto;
}
.shot-copy .field-visual {
  flex: 1 1 auto;
  min-height: 132px;
  overflow: hidden;
}
.shot-copy .field-visual textarea {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: auto;
  resize: none;
  line-height: 1.45;
}
.shot-copy .field-motion {
  flex: 0 0 auto;
  min-height: 96px;
}
.shot-copy .field-motion textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.4;
}
.shot-copy .field-dialogue {
  flex: 0 0 auto;
  min-height: 88px;
}
.shot-copy .field-dialogue textarea {
  min-height: 68px;
  resize: vertical;
  line-height: 1.4;
}
.shot-copy .field-audio {
  flex: 0 0 auto;
  min-height: 72px;
}
.shot-copy .field-audio textarea {
  min-height: 52px;
  resize: vertical;
  line-height: 1.4;
}
.shot-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 420px;
  height: 100%;
  align-self: stretch;
}
.shot-preview-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  height: 100%;
}
.shot-preview-slot {
  flex: 1 1 auto;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}
.shot-preview-slot[hidden] {
  display: none !important;
}
.shot-preview-toggle {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  margin-top: auto;
  justify-content: center;
}
.shot-preview-toggle .btn {
  flex: 1 1 0;
  text-align: center;
}
.shot-preview {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  aspect-ratio: 9 / 16;
  height: auto;
  min-height: 240px;
  max-height: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #0b0c0f;
  padding: 0;
  cursor: pointer;
}
.shot-preview img,
.shot-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0b0c0f;
}
.shot-preview-video {
  cursor: default;
}
.shot-preview-empty {
  color: var(--muted);
  font-size: 12px;
  cursor: default;
  border-style: dashed;
  background: var(--bg);
}
.shot-bind-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px 14px;
  flex: 0 0 auto;
}
.shot-bind-row .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.shot-bind-row .field > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.shot-bind-row .field-voice select,
.shot-bind-row .field-voice textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 34px;
  text-overflow: ellipsis;
}
.shot-bind-row .id-picker-list {
  left: 0;
  right: auto;
  width: min(100%, 320px);
}
.board-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.board-switcher .card-switcher-label {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.board-switcher .card-id-rail {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
  gap: 6px;
  scrollbar-width: thin;
}
.board-switcher .card-id-chip {
  flex: 0 0 auto;
  min-width: 44px;
  text-align: center;
  font-weight: 600;
}
.board-cards.card-deck {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  overflow: auto;
  container-type: inline-size;
  container-name: board;
}
.board-cards .card-stage {
  padding: 12px;
  min-width: 649px;
  min-height: 720px;
}
/* 按分镜框自身宽度折行，避免整窗 1100px 时主栏还很宽就改成单列 */
@container board (max-width: 560px) {
  .shot-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 1fr);
  }
  .shot-preview { min-height: 280px; max-height: none; }
  .shot-meta-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shot-bind-row {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .entity-card-body { grid-template-columns: 1fr; }
}

/* —— Studio Infinite Canvas（圣经 / 分镜） —— */
.studio-canvas-mode {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.studio-canvas-mode .btn {
  padding: 3px 10px;
  font-size: 12px;
}
.bible-canvas-sec .studio-canvas {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
}
.studio-unified-canvas-sec {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}
.board-canvas-wrap .studio-unified-canvas-sec {
  border: none;
  min-height: 0;
}
.board-canvas-wrap .studio-unified-canvas-sec .studio-canvas {
  border: 1px solid var(--line);
}
.studio-canvas {
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  height: 100%;
  outline: none;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 0)
    0 0 / 18px 18px,
    var(--bg-2);
}
.studio-canvas-hint {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 11px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.studio-canvas-viewport {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.studio-canvas-viewport:active {
  cursor: grabbing;
}
.studio-canvas-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
  will-change: transform;
}
.studio-canvas-edges {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  width: 8000px;
  height: 8000px;
  pointer-events: none;
  z-index: 1;
}
.studio-canvas-edge-line {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 55%, var(--line));
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* 底轨：淡实线，锚定端口 */
.studio-canvas-edge-line-base {
  opacity: 0.38;
  stroke-dasharray: none;
}
/* 流动段：沿 pathLength=100 从起点源源不断滑向终点 */
.studio-canvas-edge-line-flow {
  stroke-dasharray: 14 86;
  stroke-dashoffset: 0;
  opacity: 0.95;
  animation: studio-canvas-edge-flow 1.15s linear infinite;
  pointer-events: none;
}
@keyframes studio-canvas-edge-flow {
  to {
    stroke-dashoffset: -100;
  }
}
.studio-canvas-edge[data-edge-kind="seq"] .studio-canvas-edge-line {
  stroke: color-mix(in srgb, var(--muted) 80%, var(--line));
  stroke-width: 1.5;
}
.studio-canvas-edge[data-edge-kind="seq"] .studio-canvas-edge-line-flow {
  stroke-dasharray: 10 90;
  animation-duration: 1.4s;
}
.studio-canvas-edge[data-edge-kind="base"] .studio-canvas-edge-line {
  stroke: color-mix(in srgb, #7aa2ff 70%, var(--accent));
}
.studio-canvas-edge[data-edge-kind="mount"] .studio-canvas-edge-line,
.studio-canvas-edge[data-edge-kind="fixed"] .studio-canvas-edge-line {
  stroke: color-mix(in srgb, #6bcf8e 65%, var(--accent));
}
.studio-canvas-edge[data-edge-kind="ref"] .studio-canvas-edge-line {
  stroke: color-mix(in srgb, #e6a23c 75%, var(--accent));
  stroke-width: 2;
}
.studio-canvas-edge[data-edge-kind="ref"] .studio-canvas-edge-line-flow {
  stroke-dasharray: 12 88;
  animation-duration: 1s;
}
@media (prefers-reduced-motion: reduce) {
  .studio-canvas-edge-line-flow {
    animation: none;
    stroke-dasharray: 10 8;
    opacity: 0.75;
  }
}
.studio-canvas-node[data-node-kind="compose"] {
  outline: 1px dashed color-mix(in srgb, #e6a23c 55%, var(--line));
}
.studio-canvas-node[data-node-kind="import"] {
  outline: 1px dashed color-mix(in srgb, var(--muted) 50%, var(--line));
}
.studio-canvas-node-actions {
  display: flex;
  gap: 4px;
  padding: 0 6px 6px;
}
.studio-canvas-edge-temp {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 14 86;
  stroke-linecap: round;
  opacity: 0.9;
  pointer-events: none;
  animation: studio-canvas-edge-flow 0.9s linear infinite;
}
.studio-canvas-edge-label {
  fill: var(--muted);
  font-size: 10px;
  pointer-events: none;
  user-select: none;
}
.studio-canvas-edge-hit {
  fill: color-mix(in srgb, var(--bg) 70%, #c44);
  stroke: #c44;
  stroke-width: 1;
  pointer-events: all;
  cursor: pointer;
  opacity: 0.92;
}
.studio-canvas-edge-x {
  fill: #fff;
  font-size: 12px;
  font-weight: 700;
  pointer-events: all;
  cursor: pointer;
  user-select: none;
}
.studio-canvas-node {
  position: absolute;
  left: 0;
  top: 0;
  width: 148px;
  box-sizing: border-box;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 60%, transparent);
  cursor: grab;
  user-select: none;
}
.studio-canvas-node.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.studio-canvas-node.is-edge-snap {
  z-index: 5;
  border-color: color-mix(in srgb, #e6a23c 80%, var(--accent));
  box-shadow: 0 0 0 2px color-mix(in srgb, #e6a23c 55%, transparent);
}
.studio-canvas-node.is-edge-snap .studio-canvas-port.is-in {
  transform: translateY(-50%) scale(1.35);
  background: color-mix(in srgb, #e6a23c 75%, var(--accent));
}
.studio-canvas-node[data-node-kind="shot"] {
  width: 156px;
}
.studio-canvas-node-media {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 118px;
  border-radius: 6px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg-2) 80%, #000);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}
.studio-canvas-node-media:hover {
  outline: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
.studio-canvas-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.studio-canvas-ph {
  font-size: 11px;
  color: var(--muted);
}
.studio-canvas-node-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.studio-canvas-node-title-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.studio-canvas-node-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-canvas-node-title.is-renameable {
  cursor: text;
}
.studio-canvas-copy-name {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}
.studio-canvas-copy-name:hover {
  color: var(--text);
  background: var(--bg-2);
}
.studio-canvas-node-sub {
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-canvas-node-actions {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.studio-canvas-node-actions .btn {
  padding: 2px 8px;
  font-size: 11px;
}
.studio-canvas-port {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--accent);
  padding: 0;
  cursor: crosshair;
  z-index: 4;
}
.studio-canvas-port::before {
  content: "";
  position: absolute;
  inset: -10px;
}
.studio-canvas-port.is-in {
  left: -8px;
}
.studio-canvas-port.is-out {
  right: -8px;
}
.studio-canvas-port:hover {
  transform: scale(1.15);
}

/* 画布内原图/视频灯箱（不切卡片模式） */
.studio-media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  padding: 24px;
}
.studio-media-lightbox.hidden {
  display: none !important;
}
.studio-media-lightbox-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(920px, 96vw);
  max-height: min(92vh, 960px);
  width: 100%;
}
.studio-media-lightbox-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f4f4f5;
}
.studio-media-lightbox-path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  opacity: 0.9;
}
.studio-media-lightbox-toggle {
  display: inline-flex;
  gap: 4px;
}
.studio-media-lightbox-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #0a0a0b;
  border-radius: 8px;
  overflow: auto;
  max-height: calc(92vh - 52px);
}
.studio-media-lightbox-stage img,
.studio-media-lightbox-stage video {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 64px);
  object-fit: contain;
}

/* —— AI 角色库侧栏 —— */
.charlib-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.charlib-tab {
  flex: 1;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border, #3a3a3e);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
}
.charlib-tab.active {
  background: var(--accent, #3b6fd9);
  border-color: transparent;
  color: #fff;
}
.charlib-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.charlib-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted, #9a9aa0);
}
.charlib-pill select {
  max-width: 96px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border, #3a3a3e);
  background: var(--panel, #1e1e22);
  color: inherit;
  font-size: 11px;
  padding: 0 6px;
}
.charlib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.charlib-card {
  border: 1px solid var(--border, #3a3a3e);
  border-radius: 10px;
  padding: 6px;
  background: var(--panel-2, #25252a);
}
.charlib-card.selected {
  border-color: var(--accent, #3b6fd9);
}
.charlib-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.charlib-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.charlib-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.charlib-meta {
  font-size: 10px;
  margin: 2px 0 6px;
}
.charlib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.charlib-actions .btn {
  font-size: 11px;
  padding: 2px 6px;
}
