/* ── CSS 变量 & 全局重置 ── */
:root {
  --bg-color:        #0f1115;
  --side-bg:         #15191e;
  --card-bg:         #1c2128;
  --accent-blue:     #539bf5;
  --accent-orange:   #e8a440;
  --accent-purple:   #a78bfa;
  --text-primary:    #ffffff;
  --text-secondary:  #8b949e;
  --border-color:    #30363d;
  --hover-bg:        rgba(255,255,255,0.05);
  --success:         #2ea043;
  --warning:         #d29922;
  --danger:          #f85149;

  /* layout */
  --sidebar-w:  240px;
  /* 中间操作区宽度：对齐参考截图 100% 缩放视觉 */
  --console-w:  460px;
  /* 右侧预览区：尽量保持更宽（参考图右侧占比更大） */
  --preview-min-w: 520px;
  --header-h:   56px;
}

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

html {
  color-scheme: dark;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.ok   { color: var(--success); }
.warn { color: var(--warning); }
.err  { color: var(--danger); }

/* ── 顶部 Header ── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--side-bg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

/* Logo 区（左） */
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 var(--sidebar-w);
  min-width: 0;
}

.header-logo .logo-image {
  height: 26px;
  width: auto;
  display: block;
}

.header-logo .logo-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  flex-shrink: 0;
}

.header-logo .logo-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* 标题居中（参考前端参考.html header-center 缩放样式） */
.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 16px;
  min-width: 0;
}

.header-center .stacked {
  display: grid;
  gap: 2px;
  text-align: center;
  min-width: 0;
}

.header-center .headline {
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-center .subtitle {
  font-size: clamp(10px, 0.85vw, 12px);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-blue { color: var(--accent-blue); }

/* 用户区（右） */
.header-user {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.header-user:hover { background: var(--hover-bg); }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ── 确保主操作区文字在深色背景下可见 ── */
.main-console {
  color: var(--text-primary);
}

/* ── 应用主体布局 ── */
.app-layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--console-w) 6px 1fr;
  overflow: hidden;
  height: calc(100vh - var(--header-h));
}

/* 剪辑模式全屏：隐藏右侧预览区与分割条，中间区占满，使用百分比适应 */
.app-layout.editor-full-width {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.app-layout.editor-full-width .preview-panel,
.app-layout.editor-full-width .resize-handle {
  display: none !important;
}
.app-layout.editor-full-width .main-console {
  width: 100%;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── 拖拽分割条 ── */
.resize-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--border-color);
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}
.resize-handle:hover,
.resize-handle.dragging {
  background: var(--accent-blue);
}
.resize-handle::after {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

/* ── 通用 panel 卡片 ── */
.panel {
  background: var(--side-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-title .material-symbols-rounded { font-size: 16px; color: var(--text-secondary); }

/* ── 通用输入 ── */
.input-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

textarea, select, input[type="text"], input[type="number"] {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.2s;
  outline: none;
}
textarea:focus, select:focus, input:focus {
  border-color: var(--accent-blue);
}
textarea { resize: vertical; min-height: 80px; }

select option {
  background: #1c2128;
  color: #ffffff;
}

/* ── 栅格 ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ── Toggle Switch ── */
.toggle-row { display: flex; align-items: center; gap: 8px; }
.toggle-switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  transition: 0.25s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: 0.25s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-purple); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── 徽章 ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-itv   { background: rgba(83,155,245,.15);  color: #539bf5; }
.badge-img   { background: rgba(52,211,153,.15);  color: #34d399; }
.badge-vid   { background: rgba(167,139,250,.15); color: #a78bfa; }
.badge-veo   { background: rgba(83,155,245,.15);  color: #539bf5; }
.badge-nova  { background: rgba(232,164,64,.15);  color: #e8a440; }
.badge-wan   { background: rgba(167,139,250,.15); color: #a78bfa; }

/* ── 信息条 ── */
.info-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(83,155,245,.3);
  background: rgba(83,155,245,.07);
  font-size: 12px;
  color: var(--text-secondary);
}
.info-bar .material-symbols-rounded { font-size: 15px; flex-shrink: 0; }
.info-bar.warn-bar { border-color: rgba(232,164,64,.3); background: rgba(232,164,64,.07); }

/* ── Debug 浮窗 ── */
#debug-toggle {
  position: fixed; bottom: 18px; right: 18px; z-index: 1000;
  width: 38px; height: 38px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  font-size: 16px;
  transition: 0.2s;
  color: var(--text-secondary);
}
#debug-toggle:hover { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

#debug-panel {
  position: fixed; bottom: 66px; right: 18px; z-index: 999;
  width: 480px; max-height: 400px;
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
}
#debug-panel.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
#debug-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border-color);
  background: var(--side-bg);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
#debug-toolbar span { color: var(--accent-blue); }
#debug-clear { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 11px; }
#debug-clear:hover { color: var(--danger); }
#debug-log {
  flex: 1; overflow-y: auto;
  padding: 8px 10px;
  font-family: 'Consolas','Fira Mono',monospace;
  font-size: 11px; line-height: 1.55;
}
.dlog { padding: 3px 6px; border-radius: 4px; margin-bottom: 3px; word-break: break-all; }
.dlog-info { color: #8b949e; }
.dlog-req  { color: #79c0ff; }
.dlog-res  { color: #56d364; }
.dlog-err  { color: #f85149; background: rgba(248,81,73,.08); }
.dlog-tag {
  display: inline-block;
  padding: 1px 5px; border-radius: 3px;
  margin-right: 4px; font-weight: 700; font-size: 10px;
}
.tag-info { background: #30363d; color: #8b949e; }
.tag-req  { background: #1f3d6e; color: #79c0ff; }
.tag-res  { background: #1a3a26; color: #56d364; }
.tag-err  { background: #3d1f1f; color: #f85149; }

/* ── 用户中心页（占位） ── */
.user-center-page {
  display: flex; align-items: center; justify-content: center;
  flex: 1;
  color: var(--text-secondary);
  font-size: 14px;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.user-center-page .material-symbols-rounded { font-size: 48px; opacity: 0.3; }

/* ── Quick Start 占位页 ── */
.placeholder-page {
  display: flex; align-items: center; justify-content: center;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  color: var(--text-secondary);
  width: 100%;
}
.placeholder-page .material-symbols-rounded { font-size: 52px; opacity: 0.25; }
.placeholder-page h2 { font-size: 18px; color: var(--text-primary); }
.placeholder-page p  { font-size: 13px; }

/* ── 占位/用户中心页在 main-console 中占满高度 ── */
.main-console > .placeholder-page,
.main-console > .user-center-page {
  flex: 1;
}
