/* ====================================================
   ZPWU Agent — 现代玻璃拟态 · 移动优先
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* 颜色系统 */
  --c-bg:         #080c14;
  --c-bg2:        #0d1220;
  --c-surface:    rgba(255,255,255,0.04);
  --c-surface2:   rgba(255,255,255,0.07);
  --c-border:     rgba(255,255,255,0.08);
  --c-border2:    rgba(255,255,255,0.14);
  --c-text:       #e8edf5;
  --c-text2:      #8b98b0;
  --c-text3:      #4a5568;

  /* 品牌渐变 */
  --g-blue:    linear-gradient(135deg, #2563eb, #7c3aed);
  --g-green:   linear-gradient(135deg, #059669, #0ea5e9);
  --g-orange:  linear-gradient(135deg, #f59e0b, #ef4444);
  --g-pink:    linear-gradient(135deg, #ec4899, #8b5cf6);

  /* 纯色 */
  --blue:    #3b82f6;
  --blue2:   #2563eb;
  --purple:  #8b5cf6;
  --green:   #10b981;
  --red:     #ef4444;
  --yellow:  #f59e0b;
  --cyan:    #06b6d4;

  /* 布局 */
  --header-h: 52px;
  --tab-h:    60px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
  --radius:   12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  /* 毛玻璃 */
  --glass-bg:  rgba(13,18,32,0.82);
  --glass-blur: blur(20px) saturate(180%);

  color-scheme: dark;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--c-bg); color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}

/* ── 登录页 ───────────────────────────────────────────── */
.login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}

/* 光球背景 */
.login-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.bg-orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.25;
  animation: orbFloat 8s ease-in-out infinite;
}
.orb1 { width: 400px; height: 400px; background: #3b82f6; top: -100px; right: -80px; animation-delay: 0s; }
.orb2 { width: 300px; height: 300px; background: #8b5cf6; bottom: -50px; left: -60px; animation-delay: -3s; }
.orb3 { width: 200px; height: 200px; background: #06b6d4; top: 50%; left: 40%; animation-delay: -6s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(20px, -20px) scale(1.05); }
  66%       { transform: translate(-15px, 15px) scale(0.97); }
}

.login-card {
  position: relative; z-index: 1;
  max-width: 400px; width: 100%;
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--c-border2);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}

.login-logo-wrap {
  display: flex; justify-content: center; margin-bottom: 20px;
}
.login-logo-ring {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--g-blue);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 40px rgba(59,130,246,0.4), 0 0 80px rgba(124,58,237,0.2);
  animation: logoPulse 3s ease-in-out infinite;
}
.login-logo { font-size: 2rem; }
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 40px rgba(59,130,246,0.4), 0 0 80px rgba(124,58,237,0.2); }
  50%       { box-shadow: 0 0 60px rgba(59,130,246,0.6), 0 0 100px rgba(124,58,237,0.3); }
}

.login-title    { font-size: 1.75rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.5px; }
.login-subtitle { font-size: 0.78rem; color: var(--blue); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 16px; }
.login-desc     { font-size: 0.88rem; color: var(--c-text2); line-height: 1.6; margin: 0 0 28px; }

.btn-github {
  display: inline-flex; align-items: center; gap: 10px; width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, #24292e, #1a1f24);
  color: #fff; text-decoration: none;
  padding: 13px 20px; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: all 0.2s;
}
.btn-github:hover { background: linear-gradient(135deg, #2f363d, #22272e); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.btn-github:active { transform: translateY(0); }

.login-features {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  margin-top: 24px;
}
.login-feature {
  font-size: 0.76rem; color: var(--c-text2);
  display: flex; align-items: center; gap: 5px;
}
.feat-icon { font-size: 0.85rem; }

.login-status { margin-top: 14px; font-size: 0.8rem; color: var(--c-text2); min-height: 1.2em; }

/* ── App Header ────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--header-h);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.glass-header {
  background: rgba(8,12,20,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--c-border);
}
.header-brand { display: flex; align-items: center; gap: 8px; }
.header-logo  { font-size: 1.2rem; }
.header-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.3px; }
.header-badge {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.08em;
  padding: 2px 7px; border-radius: 20px;
  background: var(--g-blue); color: #fff;
  text-transform: uppercase;
}
.header-actions { margin-left: auto; }
.header-user    { display: flex; align-items: center; gap: 8px; }
.header-avatar  { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--c-border2); }
.header-login   { font-size: 0.82rem; color: var(--c-text2); }

/* ── Tab 导航 ────────────────────────────────────────────── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(8,12,20,0.9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--c-border);
}

.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; color: var(--c-text3);
  cursor: pointer; padding: 8px 0; position: relative;
  transition: color 0.2s; -webkit-tap-highlight-color: transparent;
}
.tab-btn::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 0; height: 2px; border-radius: 0 0 2px 2px;
  background: var(--g-blue); transition: width 0.25s cubic-bezier(.34,1.56,.64,1);
}
.tab-btn.active { color: var(--blue); }
.tab-btn.active::before { width: 28px; }
.tab-icon  { font-size: 1.2rem; line-height: 1; }
.tab-label { font-size: 0.68rem; font-weight: 500; }

/* ── Tab 内容 ─────────────────────────────────────────────── */
.tab-content {
  position: fixed; top: var(--header-h); left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-b)); overflow: hidden;
}
.tab-panel { position: absolute; inset: 0; display: none; overflow: hidden; }
.tab-panel.active { display: flex; flex-direction: column; }

/* ── 滚动面板 ───────────────────────────────────────────────── */
.panel-scroll {
  flex: 1; overflow-y: auto; padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── Section Header ─────────────────────────────────────────── */
.section-header { padding: 4px 0 16px; }
.section-title  { font-size: 1.1rem; font-weight: 700; margin: 0 0 4px; }
.section-desc   { font-size: 0.82rem; color: var(--c-text2); margin: 0; }

/* ── Glass Card ─────────────────────────────────────────────── */
.glass-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card-title { font-size: 0.82rem; font-weight: 600; color: var(--c-text2); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 14px; }
.card-desc  { font-size: 0.8rem; color: var(--c-text2); margin: -6px 0 12px; line-height: 1.5; }
.card-desc code { background: var(--c-surface2); padding: 1px 5px; border-radius: 4px; font-size: 0.78rem; }

/* ── 表单 ───────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.form-full { grid-column: 1 / -1; }

.form-label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.78rem; font-weight: 500; color: var(--c-text2);
}
.form-input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--c-border2);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  padding: 9px 12px;
  font-size: 0.88rem; font-family: inherit;
  outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-textarea { resize: vertical; min-height: 60px; }

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

/* ── 按钮 ───────────────────────────────────────────────────── */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 600; font-family: inherit;
  cursor: pointer; padding: 9px 16px;
  transition: all 0.18s; -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--g-blue); color: #fff;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(37,99,235,0.5); transform: translateY(-1px); }

.btn-secondary {
  background: var(--c-surface2); color: var(--c-text);
  border: 1px solid var(--c-border2);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-border2); }

.btn-ghost {
  background: transparent; color: var(--c-text2);
  border: 1px solid var(--c-border);
}
.btn-ghost:hover:not(:disabled) { color: var(--c-text); border-color: var(--c-border2); }

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #991b1b); color: #fff;
  box-shadow: 0 4px 12px rgba(220,38,38,0.3);
}

/* ── 对话布局 ────────────────────────────────────────────────── */
.chat-layout { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-status-bar {
  display: flex; gap: 6px; padding: 8px 12px; flex-shrink: 0;
  background: var(--c-bg2); border-bottom: 1px solid var(--c-border);
}
.status-chip {
  display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 20px; padding: 5px 5px 5px 10px;
}
.chip-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; animation: chipPulse 2s infinite;
}
.status-chip-blue .chip-dot { background: var(--blue); }
.status-chip-green .chip-dot { background: var(--green); }
@keyframes chipPulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}
.chip-text {
  flex: 1; font-size: 0.73rem; color: var(--c-text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-btn {
  width: 20px; height: 20px; border-radius: 50%; padding: 0;
  background: var(--c-surface2); border: 1px solid var(--c-border2);
  font-size: 0.75rem; color: var(--c-text2); flex-shrink: 0;
  line-height: 1;
}
.chip-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

/* 上下文条 */
.context-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; flex-shrink: 0;
  background: rgba(37,99,235,0.1); border-bottom: 1px solid rgba(37,99,235,0.2);
}
.context-icon { font-size: 0.85rem; }
.context-name { flex: 1; font-size: 0.78rem; color: var(--blue); font-family: monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-close {
  background: none; border: none; padding: 2px 6px;
  font-size: 0.8rem; color: var(--c-text2); border-radius: 4px;
}
.context-close:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* 消息列表 */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* 用户/AI 气泡 */
.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-ai   { justify-content: flex-start; }

.chat-bubble {
  max-width: 82%; padding: 11px 14px;
  font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  animation: bubbleIn 0.2s ease;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-msg-user .chat-bubble {
  background: var(--g-blue); color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.chat-msg-ai .chat-bubble {
  background: var(--c-surface2); color: var(--c-text);
  border: 1px solid var(--c-border2);
  border-radius: 18px 18px 18px 4px;
}

.chat-sys     { text-align: center; font-size: 0.75rem; color: var(--c-text3); padding: 2px 0; }
.chat-sys-err { color: var(--red); }

/* Agent 事件气泡 */
.agent-event {
  border-radius: 10px; font-size: 0.81rem; padding: 10px 12px;
  border-left: 3px solid; background: var(--c-surface);
  animation: bubbleIn 0.2s ease;
}
.agent-thinking {
  display: flex; align-items: flex-start; gap: 8px;
  border-left-color: var(--purple); color: var(--c-text2);
}
.agent-thinking.agent-err { border-left-color: var(--red); color: var(--red); }
.agent-icon { font-size: 0.95rem; flex-shrink: 0; margin-top: 1px; }
.agent-text { flex: 1; line-height: 1.5; }

/* 工具调用卡片 */
.agent-tool { border-left-color: var(--yellow); padding: 0; overflow: hidden; }
.tool-header {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: rgba(245,158,11,0.08);
}
.tool-icon { font-size: 0.95rem; }
.tool-name { font-weight: 600; color: #fbbf24; flex: 1; font-size: 0.82rem; }
.tool-status { font-size: 0.7rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.tool-status.running { background: rgba(245,158,11,0.2); color: var(--yellow); }
.tool-status.done    { background: rgba(16,185,129,0.15); color: var(--green); }
.tool-status.fail    { background: rgba(239,68,68,0.15); color: var(--red); }
.tool-input {
  font-family: 'Menlo','Consolas','Courier New',monospace; font-size: 0.73rem;
  color: var(--c-text2); margin: 0; padding: 6px 12px;
  background: none; border-top: 1px solid rgba(255,255,255,0.04);
  white-space: pre-wrap; word-break: break-all; max-height: 80px; overflow-y: auto;
}
.tool-result-area { border-top: 1px solid rgba(255,255,255,0.04); }
.tool-result {
  font-family: 'Menlo','Consolas','Courier New',monospace; font-size: 0.73rem;
  color: #86efac; margin: 0; padding: 6px 12px;
  white-space: pre-wrap; word-break: break-all; max-height: 120px; overflow-y: auto;
}

/* 输入区 */
.chat-input-wrap {
  padding: 10px 12px 12px; flex-shrink: 0;
  border-top: 1px solid var(--c-border);
}
.glass-input {
  background: rgba(8,12,20,0.9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.system-input {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--c-text2); font-family: inherit; font-size: 0.78rem;
  padding: 4px 0 8px; border-bottom: 1px solid var(--c-border);
  margin-bottom: 10px;
}
.system-input::placeholder { color: var(--c-text3); }

/* 开关 */
.agent-toggle-row { margin-bottom: 10px; }
.toggle-label {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
}
.toggle-wrap { position: relative; flex-shrink: 0; }
.toggle-input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.toggle-track {
  display: block; width: 36px; height: 20px; border-radius: 20px;
  background: var(--c-surface2); border: 1px solid var(--c-border2);
  transition: background 0.2s, border-color 0.2s;
}
.toggle-input:checked ~ .toggle-track {
  background: var(--g-blue); border-color: transparent;
  box-shadow: 0 0 12px rgba(37,99,235,0.4);
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1);
}
.toggle-input:checked ~ .toggle-thumb { transform: translateX(16px); }
.toggle-text { font-size: 0.8rem; color: var(--c-text2); user-select: none; }

.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row textarea {
  flex: 1; background: var(--c-surface); border: 1px solid var(--c-border2);
  border-radius: var(--radius); color: var(--c-text);
  font-family: inherit; font-size: 0.9rem; line-height: 1.5;
  padding: 10px 12px; margin: 0; outline: none; resize: none;
  min-height: 54px; max-height: 140px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input-row textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.send-btn {
  width: 46px; height: 46px; border-radius: 12px; padding: 0;
  background: var(--g-blue);
  box-shadow: 0 4px 16px rgba(37,99,235,0.4); flex-shrink: 0; align-self: flex-end;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.55); }
.send-btn:active:not(:disabled) { transform: translateY(0); }

.agent-hint { font-size: 0.76rem; color: var(--yellow); padding: 4px 0 0; }

/* ── 文件布局 ─────────────────────────────────────────────── */
.file-layout { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.repo-bar {
  display: flex; gap: 6px; align-items: center;
  padding: 8px 12px; flex-shrink: 0; border-bottom: 1px solid var(--c-border);
}
.glass-bar {
  background: rgba(8,12,20,0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.repo-select {
  flex: 1; background: var(--c-surface); border: 1px solid var(--c-border2);
  border-radius: var(--radius-sm); color: var(--c-text);
  padding: 7px 10px; font-size: 0.82rem; font-family: inherit; outline: none;
  min-width: 0;
}
.branch-input {
  width: 80px; background: var(--c-surface); border: 1px solid var(--c-border2);
  border-radius: var(--radius-sm); color: var(--c-text);
  padding: 7px 8px; font-size: 0.82rem; font-family: inherit; outline: none;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm); padding: 0;
  background: var(--c-surface2); border: 1px solid var(--c-border2); color: var(--c-text2);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.icon-btn-sm {
  width: 28px; height: 28px; border-radius: var(--radius-sm); padding: 0;
  background: transparent; border: 1px solid var(--c-border); color: var(--c-text3);
}
.icon-btn-sm:hover { background: var(--c-surface2); color: var(--c-text); }

.file-tree-pane {
  display: flex; flex-direction: column; border-bottom: 1px solid var(--c-border);
  flex: 0 0 38%; overflow: hidden;
}
.file-editor-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.pane-header {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: var(--c-bg2); border-bottom: 1px solid var(--c-border);
  min-height: 38px; flex-shrink: 0;
}
.pane-path {
  flex: 1; font-size: 0.75rem; color: var(--c-text2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace;
}
.pane-actions { display: flex; gap: 6px; }

.action-btn {
  height: 28px; padding: 0 10px; border-radius: 6px; font-size: 0.75rem;
  background: var(--c-surface2); border: 1px solid var(--c-border2); color: var(--c-text2);
}
.action-btn:hover:not(:disabled) { background: var(--c-border2); color: var(--c-text); }
.action-btn-primary {
  background: linear-gradient(135deg, rgba(37,99,235,0.3), rgba(124,58,237,0.3));
  border-color: rgba(59,130,246,0.4); color: var(--blue);
}
.action-btn-primary:hover:not(:disabled) {
  background: var(--g-blue); color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.file-tree { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.empty-hint { padding: 16px; color: var(--c-text3); font-size: 0.82rem; margin: 0; text-align: center; }
.tree-err   { color: rgba(239,68,68,0.8); }

.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-item { border-bottom: 1px solid rgba(255,255,255,0.03); }
.tree-btn {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--c-text); padding: 9px 14px;
  font-size: 0.84rem; font-weight: 400; border-radius: 0;
  justify-content: flex-start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.1s;
}
.tree-dir .tree-btn { color: var(--cyan); }
.tree-btn:hover { background: var(--c-surface2); }

.code-editor {
  flex: 1; resize: none; border-radius: 0; border: none;
  border-bottom: 1px solid var(--c-border);
  background: rgba(0,0,0,0.4); color: var(--c-text);
  font-family: 'Menlo','Consolas','Courier New',monospace;
  font-size: 0.82rem; line-height: 1.6; padding: 12px;
  margin: 0; outline: none; width: 100%;
  -webkit-overflow-scrolling: touch;
}

.editor-footer { padding: 8px 12px; background: var(--c-bg2); flex-shrink: 0; }
.commit-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.commit-label { font-size: 0.75rem; color: var(--c-text2); white-space: nowrap; }
.commit-input {
  flex: 1; background: var(--c-surface); border: 1px solid var(--c-border2);
  border-radius: 6px; color: var(--c-text); padding: 6px 10px;
  font-size: 0.8rem; font-family: inherit; outline: none;
}
.commit-input:focus { border-color: var(--blue); }
.editor-status {
  font-size: 0.75rem; color: var(--c-text2); min-height: 18px;
  display: flex; align-items: center; gap: 6px;
}
.editor-status.ok  { color: var(--green); }
.editor-status.err { color: var(--red); }

/* ── Provider 卡片 ─────────────────────────────────────────── */
.pv-list { display: flex; flex-direction: column; gap: 10px; }

.pv-card {
  background: rgba(0,0,0,0.25); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 12px; position: relative; overflow: hidden;
}
.pv-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--g-blue); opacity: 0; transition: opacity 0.2s;
}
.pv-active::before { opacity: 1; }
.pv-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pv-name  { font-weight: 600; font-size: 0.9rem; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.pv-kind  { font-size: 0.68rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.pv-kind-openai { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.pv-kind-claude { background: rgba(139,92,246,0.15); color: #c084fc; border: 1px solid rgba(139,92,246,0.3); }
.pv-model { font-size: 0.78rem; color: var(--c-text2); margin-bottom: 2px; }
.pv-url   { font-size: 0.72rem; color: var(--c-text3); margin-bottom: 10px; font-family: monospace; overflow: hidden; text-overflow: ellipsis; }
.pv-actions { display: flex; gap: 6px; }
.pv-actions button { font-size: 0.75rem; padding: 5px 12px; height: 28px; }

/* ── 用户资料 ───────────────────────────────────────────────── */
.user-profile { display: flex; align-items: center; gap: 14px; padding: 4px 0; }
.user-avatar  { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--c-border2); }
.user-name    { font-size: 1rem; font-weight: 600; margin-bottom: 3px; }
.user-login   { font-size: 0.8rem; color: var(--c-text2); }

/* ── 健康状态 ───────────────────────────────────────────────── */
.health-status {
  font-size: 0.82rem; color: var(--c-text2); padding: 10px 12px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); word-break: break-all;
}

/* ── 通用状态 ───────────────────────────────────────────────── */
.status-ok  { color: var(--green) !important; }
.status-err { color: var(--red) !important; }

/* ── 滚动条美化 ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text3); }

/* ── 无障碍辅助 ─────────────────────────────────────────────── */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Tab Badge ─────────────────────────────────────────────── */
.tab-badge {
  min-width: 16px; height: 16px; border-radius: 20px;
  background: var(--red); color: #fff;
  font-size: 0.6rem; font-weight: 700; line-height: 16px;
  padding: 0 4px; text-align: center;
  position: absolute; top: 4px; right: 4px;
}

/* ── 草稿箱工具栏 ───────────────────────────────────────────── */
.draft-toolbar {
  display: flex; gap: 8px; margin-bottom: 12px;
}

/* ── 草稿卡片 ───────────────────────────────────────────────── */
.draft-list { display: flex; flex-direction: column; gap: 12px; }

.draft-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 14px; overflow: hidden;
  border-left: 3px solid var(--yellow);
  animation: bubbleIn 0.2s ease;
}

.draft-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap;
}
.draft-repo   { font-weight: 600; font-size: 0.88rem; color: var(--c-text); }
.draft-branch { font-size: 0.75rem; color: var(--cyan); font-family: monospace; }
.draft-ts     { margin-left: auto; font-size: 0.7rem; color: var(--c-text3); }

.draft-path {
  font-family: 'Menlo','Consolas','Courier New',monospace;
  font-size: 0.78rem; color: var(--blue); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.draft-commit {
  font-size: 0.76rem; color: var(--c-text2); margin-bottom: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 内容预览 */
.draft-preview { margin-bottom: 10px; }
.draft-preview-toggle {
  font-size: 0.76rem; color: var(--c-text2); cursor: pointer; user-select: none;
  padding: 4px 0; list-style: none;
}
.draft-preview-toggle::-webkit-details-marker { display: none; }
.draft-preview-toggle::before { content: '▶ '; }
details[open] .draft-preview-toggle::before { content: '▼ '; }
.draft-content {
  margin: 8px 0 0; padding: 10px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: 'Menlo','Consolas','Courier New',monospace;
  font-size: 0.73rem; color: var(--c-text2);
  white-space: pre-wrap; word-break: break-all;
  max-height: 200px; overflow-y: auto;
}

/* 提交信息编辑行 */
.draft-commit-row { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.draft-commit-input {
  width: 100%; background: var(--c-surface); border: 1px solid var(--c-border2);
  border-radius: 6px; color: var(--c-text); padding: 6px 10px;
  font-size: 0.8rem; font-family: inherit; outline: none;
}
.draft-commit-input:focus { border-color: var(--blue); }

.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.draft-actions button { font-size: 0.78rem; padding: 6px 14px; }

/* diff 统计 */
.diff-stat {
  font-size: 0.75rem; margin-bottom: 8px; display: flex; gap: 8px; align-items: center;
}
.diff-stat-add { color: #4ade80; font-weight: 600; }
.diff-stat-del { color: #f87171; font-weight: 600; }
.diff-stat-none { color: var(--c-text3); }

/* diff 容器 */
.draft-diff-wrap { margin-bottom: 10px; }
.diff-view {
  margin-top: 8px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: 'Menlo','Consolas','Courier New',monospace;
  font-size: 0.72rem; line-height: 1.55;
  overflow-x: auto; overflow-y: auto;
  max-height: 320px;
}
.diff-view div { padding: 1px 10px; white-space: pre; }
.diff-add  { background: rgba(74,222,128,0.12); color: #4ade80; }
.diff-del  { background: rgba(248,113,113,0.12); color: #f87171; text-decoration: line-through; }
.diff-eq   { color: var(--c-text2); }
.diff-ctx  { color: var(--c-text3); padding: 2px 10px; font-style: italic; font-size: 0.68rem; }

.draft-status {
  font-size: 0.75rem; color: var(--c-text2); min-height: 18px; margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}
.draft-status.ok  { color: var(--green); }
.draft-status.err { color: var(--red); }

/* ── Agent 授权卡片 ──────────────────────────────────────── */
.agent-approval {
  border-left-color: var(--purple);
  padding: 0; overflow: hidden;
  animation: bubbleIn 0.2s ease;
}
.approval-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: rgba(139,92,246,0.1);
}
.approval-icon { font-size: 1rem; }
.approval-title { font-weight: 600; color: var(--purple); flex: 1; font-size: 0.84rem; }
.approval-badge {
  font-size: 0.7rem; padding: 2px 9px; border-radius: 20px; font-weight: 600;
}
.approval-badge.pending  { background: rgba(245,158,11,0.2); color: var(--yellow); }
.approval-badge.approved { background: rgba(16,185,129,0.15); color: var(--green); }
.approval-badge.rejected { background: rgba(239,68,68,0.15); color: var(--red); }

.approval-path {
  font-family: 'Menlo','Consolas','Courier New',monospace;
  font-size: 0.78rem; color: var(--blue); padding: 6px 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.approval-commit {
  font-size: 0.76rem; color: var(--c-text2); padding: 4px 12px 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.approval-preview-wrap { margin: 0 12px 10px; }
.approval-actions {
  display: flex; gap: 8px; padding: 0 12px 12px; flex-wrap: wrap;
}
.approval-actions button { font-size: 0.78rem; padding: 7px 16px; }
.approval-status {
  font-size: 0.73rem; color: var(--red); padding: 0 12px 8px; min-height: 16px;
}

/* ── 桌面（≥ 680px）────────────────────────────────────────── */
@media (min-width: 680px) {
  html, body { overflow: auto; }

  .tab-bar {
    top: var(--header-h); bottom: auto; height: 48px; padding-bottom: 0;
    border-top: none; border-bottom: 1px solid var(--c-border);
    flex-direction: row; justify-content: flex-start;
    background: rgba(8,12,20,0.85);
  }
  .tab-btn {
    flex: none; flex-direction: row; gap: 7px; padding: 0 20px;
    font-size: 0.85rem;
  }
  .tab-btn::before { top: auto; bottom: 0; left: 50%; width: 0; height: 2px; border-radius: 2px 2px 0 0; }
  .tab-btn.active::before { width: 32px; }
  .tab-icon { font-size: 0.95rem; }

  .tab-content { top: calc(var(--header-h) + 48px); bottom: 0; }

  .file-layout { flex-direction: row; }
  .file-tree-pane { flex: 0 0 260px; border-right: 1px solid var(--c-border); border-bottom: none; }

  .panel-scroll { max-width: 760px; margin: 0 auto; width: 100%; padding: 20px; }

  .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
  .panel-scroll { max-width: 860px; }
}
