:root {
  --bg-dark: #0b0f19;
  --panel-bg: #111827;
  --card-bg: #182234;
  --card-hover: #1e2b42;
  --border-color: #27354f;
  --border-highlight: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.25);
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --wire-color: #38bdf8;
  --wire-active: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  user-select: none;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Header */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #ea580c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  font-size: 0.7rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #1e293b;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn:hover {
  background: #27354f;
  border-color: #3b82f6;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #b45309;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-emerald {
  background: #065f46;
  border-color: #10b981;
  color: #ecfdf5;
}

.btn-emerald:hover {
  background: #047857;
}

.btn-cyan {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent-cyan);
}

.btn-cyan:hover {
  background: rgba(56, 189, 248, 0.25);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

/* Main Workspace */
.workspace {
  display: flex;
  flex: 1;
  height: calc(100vh - 52px);
  position: relative;
  overflow: hidden;
}

/* Infinite Canvas Container */
.canvas-container {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: #080c14;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: grab;
}

.canvas-container:active {
  cursor: grabbing;
}

.canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

/* SVG Connection Lines Layer */
.wires-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  pointer-events: none;
  z-index: 10;
}

.wire-path {
  fill: none;
  stroke: var(--wire-color);
  stroke-width: 3;
  stroke-dasharray: 6 3;
  animation: wireFlow 1.2s linear infinite;
  opacity: 0.75;
}

@keyframes wireFlow {
  from { stroke-dashoffset: 9; }
  to { stroke-dashoffset: 0; }
}

/* Floating Asset Dock */
/* Floating Asset Dock (支援自由拖曳調整大小與寬度) */
.asset-dock {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 330px;
  min-width: 270px;
  max-width: 680px;
  min-height: 220px;
  max-height: calc(100vh - 75px);
  overflow: auto;
  resize: both; /* 支援右下角自由拖拉調整寬度與高度 */
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px 18px 14px;
  z-index: 40;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.65);
  transition: width 0.2s ease, border-color 0.18s ease;
}

.asset-dock:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

/* 右下角拖拉調整大小視覺提手 */
.asset-dock::after {
  content: '⇲';
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.65;
}

.asset-dock.wide-mode {
  width: 480px;
}

.asset-dock::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.asset-dock::-webkit-scrollbar-thumb {
  background: #27354f;
  border-radius: 3px;
}

.dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}

.dock-item {
  margin-bottom: 12px;
}

.dock-item-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.dock-item label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Multi-Character Asset Cards */
.char-card {
  background: #0d131f;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.char-model-id-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.5px;
}

.char-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-thumbs-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.char-slot-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.char-slot-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
}

.char-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  border: 1px dashed var(--border-color);
  background: #080c14;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.char-thumb:hover {
  border-color: var(--accent-cyan);
  transform: scale(1.04);
}

.char-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.char-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.char-name-input {
  background: #111827;
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 4px;
  outline: none;
}

.char-name-input:focus,
.char-desc-input:focus {
  border-color: var(--accent);
}

.char-desc-input {
  background: #111827;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.70rem;
  padding: 4px 6px;
  border-radius: 4px;
  outline: none;
  width: 100%;
}

.style-preview-box {
  background: #090e17;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 0.72rem;
  color: var(--accent-cyan);
  line-height: 1.45;
  margin-top: 6px;
  min-height: 72px;
  max-height: 280px;
  overflow-y: auto;
  resize: vertical; /* 支援上下拖曳展開高度 */
  user-select: text;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.4);
}

.style-preview-box::-webkit-scrollbar {
  width: 4px;
}
.style-preview-box::-webkit-scrollbar-thumb {
  background: #27354f;
  border-radius: 2px;
}

/* Shot Nodes (Cards) on Canvas */
.shot-node {
  position: absolute;
  width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 20;
  cursor: default;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.shot-node:hover {
  border-color: rgba(56, 189, 248, 0.45);
}

.shot-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow), 0 12px 36px rgba(0, 0, 0, 0.6);
}

.shot-node.running {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.35);
}

.shot-node.done {
  border-color: var(--accent-emerald);
}

.shot-node-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #111827;
  border-bottom: 1px solid var(--border-color);
  border-radius: 10px 10px 0 0;
  cursor: grab;
}

.shot-node-header:active {
  cursor: grabbing;
}

.shot-title-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.shot-spec-badge {
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.shot-num {
  font-size: 0.8rem;
  font-weight: 800;
  background: #27354f;
  color: var(--accent-cyan);
  padding: 2px 7px;
  border-radius: 4px;
}

.shot-node-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: text;
}

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

.shot-field label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.shot-field select,
.shot-field input,
.shot-field textarea {
  background: #0d131f;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--text-main);
  padding: 6px 8px;
  font-size: 0.78rem;
  font-family: inherit;
  outline: none;
}

.shot-field textarea {
  resize: vertical;
  min-height: 54px;
  line-height: 1.35;
}

.shot-field select:focus,
.shot-field input:focus,
.shot-field textarea:focus {
  border-color: var(--accent-cyan);
}

.shot-row-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Image / Video Slot (支援點擊與拖曳上傳) */
.shot-media-slot {
  width: 100%;
  height: 140px;
  background: #090e17;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.shot-media-slot:hover {
  border-color: var(--accent-cyan);
  background: #0d1522;
}

.shot-media-slot.drag-over {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
}

.slot-display {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shot-media-slot img,
.shot-media-slot video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.slot-hover-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(4, 18, 38, 0.88);
  color: var(--accent-cyan);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  padding: 4px 0;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  z-index: 6;
}

.shot-media-slot:hover .slot-hover-hint {
  opacity: 1;
}

.chain-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(56, 189, 248, 0.85);
  color: #041226;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  z-index: 5;
}

.node-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px 0;
}

.node-progress-track {
  width: 100%;
  height: 4px;
  background: #27354f;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.node-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-cyan);
  transition: width 0.2s;
}

.shot-node-footer {
  padding: 8px 12px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.6);
  border-radius: 0 0 10px 10px;
}

/* Right Assistant Sidebar */
.assistant-sidebar {
  width: 380px;
  height: 100%;
  background-color: var(--panel-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 45;
  transition: transform 0.25s ease;
}

.assistant-sidebar.collapsed {
  transform: translateX(100%);
}

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.assistant-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.assistant-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.assistant-box {
  background: #182234;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
}

.assistant-box-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.assistant-chat-stream {
  flex: 1;
  min-height: 160px;
  max-height: 260px;
  overflow-y: auto;
  background: #0d131f;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
}

.chat-msg {
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 90%;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: #1e3a8a;
  color: #e0e7ff;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

/* Toggle Floating Button when Sidebar Collapsed */
.toggle-sidebar-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 35;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
}

/* =========================================================
   Cinematic Style Manager Modal & Components
   ========================================================= */
.style-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 13, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.style-modal-container {
  background: #0d131f;
  border: 1px solid #27354f;
  border-radius: 12px;
  width: 980px;
  max-width: 94vw;
  height: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.style-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #111927;
  border-bottom: 1px solid #27354f;
}

.style-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-modal-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 400;
  margin-left: 8px;
}

.style-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left panel: Categories */
.style-cat-panel {
  width: 280px;
  background: #090e17;
  border-right: 1px solid #27354f;
  display: flex;
  flex-direction: column;
}

.style-panel-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #0f172a;
  border-bottom: 1px solid #27354f;
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
}

.style-cat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.style-cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #94a3b8;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.style-cat-item:hover {
  background: #1e293b;
  color: #e2e8f0;
}

.style-cat-item.active {
  background: #1e293b;
  color: #38bdf8;
  font-weight: 700;
  border-color: #38bdf8;
}

.style-cat-actions {
  display: flex;
  gap: 4px;
  opacity: 0.6;
}
.style-cat-item:hover .style-cat-actions {
  opacity: 1;
}

/* Right panel: Substyles */
.style-sub-panel {
  flex: 1;
  background: #0c121e;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.style-count-badge {
  font-size: 0.68rem;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.style-sub-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.style-sub-card {
  background: #131b2b;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 0.15s;
}

.style-sub-card:hover {
  border-color: #38bdf8;
}

.style-sub-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.style-sub-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
}

.style-sub-prompt-text {
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.35;
  background: #090e17;
  padding: 6px 8px;
  border-radius: 4px;
  border-left: 3px solid #38bdf8;
  font-family: monospace;
  word-break: break-word;
}

/* Candidate Pool Drawer */
.candidate-pool-drawer {
  background: #0f192b;
  border-bottom: 2px solid #38bdf8;
  padding: 10px 14px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pool-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.pool-card {
  background: #142036;
  border: 1px dashed #2e4468;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pool-card:hover {
  border-color: #38bdf8;
  border-style: solid;
  background: #1a2947;
  transform: translateY(-1px);
}

.pool-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pool-card-prompt {
  font-size: 0.65rem;
  color: #94a3b8;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: monospace;
}

/* Substyle Editor Drawer */
.substyle-editor-drawer {
  background: #101828;
  border-top: 1px solid #38bdf8;
  padding: 12px 16px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.style-input {
  width: 100%;
  background: #090e17;
  color: #fff;
  border: 1px solid #27354f;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.75rem;
  outline: none;
}
.style-input:focus {
  border-color: #38bdf8;
}

.style-textarea {
  width: 100%;
  background: #090e17;
  color: #e2e8f0;
  border: 1px solid #27354f;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.72rem;
  outline: none;
  resize: vertical;
  font-family: monospace;
}
.style-textarea:focus {
  border-color: #38bdf8;
}

.style-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: #111927;
  border-top: 1px solid #27354f;
}

/* Shot Node Ground Truth Anchoring & Fallback Controls */
.shot-anchor-bar {
  margin-bottom: 6px;
}

.anchor-override-bar {
  margin-top: 5px;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 5px;
}

.btn-amber {
  background: #f59e0b;
  color: #041226;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-amber:hover {
  background: #fbbf24;
}
.btn-amber:active {
  transform: scale(0.98);
}

/* Pose Editor Modal & Badge Styles */
.pose-modal-container {
  animation: fadeInPoseModal 0.18s ease-out;
}

@keyframes fadeInPoseModal {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.btn-warning {
  background: #f59e0b;
  color: #0f172a;
  border: none;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-warning:hover {
  background: #fbbf24;
}

.btn-warning:active {
  transform: scale(0.98);
}

.pose-indicator-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.62rem;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pose-indicator-badge:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
}



/* RWD 補強 (2026-09-24):手機寬度下頂部列換行 */
@media (max-width: 720px) {
  .top-bar { height: auto; flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .brand-section, .nav-tools { flex-wrap: wrap; gap: 6px; min-width: 0; }
}

/* =========================================================
   手機殼層 (2026-09-30):底部導覽列 + 底部抽屜 + 分鏡清單 feed
   結構複製自 manga-canvas.css 的同一組共用元件(class 名稱必須一致，
   因為 app.js 的 wfuiOpenSheet()/wfuiInitMobileTabbar() 是寫死這些 class 名稱)，
   顏色沿用本頁既有的 CSS 變數（--panel-bg/--border-color/--text-muted/--accent-cyan），
   刻意不連結 styles.css，避免它的 :root/.btn 影響桌面版既有外觀。
   ========================================================= */
.mobile-tabbar { display: none; }
.btn-mobile-only { display: none; }
.mobile-shot-feed { display: none; }

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, 0.72);
  z-index: 9990; display: none;
  align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.bottom-sheet {
  width: 100%; max-width: 640px; max-height: 85vh;
  background: var(--panel-bg); border: 1px solid var(--border-color); border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  animation: sc-sheet-in 0.22s ease-out;
  color: var(--text-main);
}
@keyframes sc-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 36px; height: 4px; border-radius: 999px; background: #334155; margin: 4px auto 14px; }
.sheet-close {
  position: sticky; top: 0; float: right; background: transparent; border: none;
  color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 6px;
}
.sc-sheet-title { font-size: 0.85rem; font-weight: 700; color: var(--text-main); margin: 0 0 10px; }
.sc-sheet-row {
  display: block; width: 100%; text-align: left;
  background: #0d131f; border: 1px solid var(--border-color); color: var(--text-main);
  padding: 10px 12px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.sc-sheet-row:active { background: #1e293b; border-color: var(--accent-cyan); }

.mobile-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 2px; border: none; background: transparent; color: var(--text-muted);
  font-size: 10.5px; font-weight: 500; cursor: pointer; border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.mobile-tab svg { width: 20px; height: 20px; }
.mobile-tab.active { color: var(--accent-cyan); }
.mobile-tab:active { background: rgba(56, 189, 248, 0.12); }

/* Mobile Shot Feed Cards (取代無限畫布 + SVG 連線) */
.mobile-shot-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-shot-card.is-running { border-color: var(--accent-cyan); box-shadow: 0 0 16px rgba(56,189,248,0.25); }
.mobile-shot-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mobile-shot-card-head h3 {
  font-size: 0.88rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-main);
  font-weight: 700;
}
.mobile-shot-num {
  font-size: 0.68rem;
  font-weight: 800;
  background: #27354f;
  color: var(--accent-cyan);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.mobile-status-pill {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: #334155; color: #94a3b8;
}
.mobile-status-pill.status-running { background: rgba(56,189,248,0.18); color: var(--accent-cyan); }
.mobile-status-pill.status-done { background: rgba(16,185,129,0.18); color: var(--accent-emerald); }
.mobile-status-pill.status-error { background: rgba(244,63,94,0.18); color: var(--accent-rose); }
.mobile-chain-badge {
  align-self: flex-start;
  font-size: 0.66rem;
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.1);
  border-radius: 999px;
  padding: 3px 9px;
}
.mobile-shot-thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 280px;
  border-radius: 8px;
  background: #090e17;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.mobile-thumb-placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
}
.mobile-shot-prompt {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mobile-shot-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.mobile-shot-meta span {
  font-size: 0.66rem;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 7px;
}
.mobile-progress-track {
  width: 100%; height: 4px; background: #27354f; border-radius: 2px; overflow: hidden;
}
.mobile-progress-fill { height: 100%; width: 0%; background: var(--accent-cyan); transition: width 0.2s; }
.mobile-shot-actions { display: flex; gap: 8px; margin-top: 2px; }
.mobile-shot-actions .btn { flex: 1; justify-content: center; padding: 8px; font-size: 0.78rem; }
.mobile-shot-actions .mobile-btn-del { flex: 0 0 auto; padding: 8px 12px; }
.mobile-add-shot-row .btn { width: 100%; justify-content: center; padding: 10px; }

/* 鏡頭卡片被「編輯」搬進底部抽屜時，取消桌面版的絕對定位/固定寬度 */
.shot-node.mobile-editing {
  position: static;
  width: 100%;
  box-shadow: none;
  z-index: auto;
}

@media (max-width: 720px) {
  .mobile-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9985;
    background: rgba(10, 15, 25, 0.94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  body.has-mobile-tabbar .app-container {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Phase：手機改用分鏡清單 feed 取代無限畫布，右側 AI 助理浮動面板整個隱藏
     （其內容改由底部抽屜承載，見 openAssistantSheet()）。
     ⚠ .canvas-container / #btn-queue-all / #btn-new-project 等 id 與 class
     同時存在於 manga-canvas.html（共用 storyboard-canvas.css 當基底樣式），
     必須用 body.storyboard-canvas-body 限定範圍，否則會連帶把 manga-canvas.html
     自己的畫布或工具列按鈕也隱藏掉。 */
  body.storyboard-canvas-body .canvas-container { display: none; }
  body.storyboard-canvas-body .assistant-sidebar { display: none; }
  .mobile-shot-feed {
    display: flex; flex-direction: column; gap: 14px;
    flex: 1; min-width: 0;
    padding: 14px 14px calc(90px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }

  .btn-mobile-only { display: inline-flex; }
  body.storyboard-canvas-body #btn-add-shot,
  body.storyboard-canvas-body #btn-queue-all,
  body.storyboard-canvas-body #btn-new-project,
  body.storyboard-canvas-body #btn-save-project,
  body.storyboard-canvas-body #btn-load-project,
  body.storyboard-canvas-body #btn-free-vram,
  body.storyboard-canvas-body #btn-reset-view,
  body.storyboard-canvas-body #btn-toggle-assistant {
    display: none;
  }

  /* 影視畫風庫管理員：桌面雙欄改單欄鑽取式導覽 (drill-down) */
  #style-manager-container {
    width: 96vw; height: 92vh;
  }
  .style-modal-body { flex-direction: column; }
  .style-cat-panel, .style-sub-panel { width: 100%; }
  #style-manager-container:not(.mobile-showing-substyles) .style-sub-panel { display: none; }
  #style-manager-container.mobile-showing-substyles .style-cat-panel { display: none; }
  #btn-style-mobile-back { display: none; }
  #style-manager-container.mobile-showing-substyles #btn-style-mobile-back { display: inline-flex; }

  /* 結尾影格微調挑選器：全螢幕化並放大觸控熱區 */
  #frame-scrubber-modal .scrubber-modal-container {
    width: 98vw !important; max-width: 98vw !important;
    height: 96vh !important; max-height: 96vh !important;
  }
  #scrubber-filmstrip {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  #scrubber-filmstrip .thumb-box {
    height: 110px !important;
  }
  #btn-scrub-back-05, #btn-scrub-back-01, #btn-scrub-fwd-01, #btn-scrub-last {
    padding: 10px 12px !important; font-size: 0.78rem !important;
  }
  #frame-scrubber-modal input[type="range"] {
    height: 28px;
  }
}
