/* --- 全局与重置 --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; background: #0f0f13; color: #e8e4dc; height: 100vh; display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased; }
input, textarea, select, button { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px;}
::-webkit-scrollbar-thumb { background: #2a2a35; border-radius: 4px; }

/* --- 顶部导航 --- */
.topnav { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid #2a2a35; background: #0f0f13; min-height: 52px; flex-shrink: 0; z-index: 100;}
.logo { font-size: 15px; font-weight: 600; color: #f0ebe0; display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #36cfc9; box-shadow: 0 0 6px #36cfc988;}
.nav-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;}
.nav-btn { background: #2a2a35; border: 1px solid #3a3a4a; color: #a09898; font-size: 12px; padding: 5px 12px; border-radius: 6px; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; text-decoration: none;}
.nav-btn:hover { background: #3a3a4a; color: #e8e4dc; border-color: #36cfc9; }
.api-badge { font-size: 12px; padding: 5px 10px; border-radius: 6px; background: #2a2a35; color: #6b6878; cursor: pointer; transition: all 0.15s; border: 1px solid #3a3a4a; white-space: nowrap;}
.api-badge.ok { background: #1a2e1a; color: #7ec97e; border-color: #2e4e2e; }

/* --- 移动端 --- */
.btn-mobile-menu { display: none; background: transparent; border: none; color: #c9a96e; font-size: 20px; cursor: pointer; padding-right: 8px;}
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 800; backdrop-filter: blur(2px);}

@media (max-width: 900px) {
    .btn-mobile-menu { display: block; }
    .left-sidebar { position: fixed; left: -100%; top: 52px; height: calc(100vh - 52px); transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 5px 0 15px rgba(0,0,0,0.5); z-index: 900; }
    .left-sidebar.open { left: 0; }
    .right-sidebar { position: fixed; right: -100%; top: 52px; height: calc(100vh - 52px); transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: -5px 0 15px rgba(0,0,0,0.5); z-index: 900; display: flex !important;}
    .right-sidebar.open { right: 0; }
    .mobile-overlay.open { display: block; }
    .topnav .nav-btn span { display: none; }
    .modal-box { width: 95%; max-height: 95vh; }
    .label-box { transform: scale(0.85); transform-origin: left center;}
}

/* --- 主体三栏 --- */
.main { flex: 1; display: flex; overflow: hidden; min-height: 0; position: relative;}

/* 左右侧栏通用 */
.sidebar { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; overflow-y: auto; background: #0c0c10; padding: 15px; padding-bottom: 150px; z-index: 900;}
.left-sidebar { border-right: 1px solid #1c1c24; }
.right-sidebar { border-left: 1px solid #1c1c24; background: #111116;}
.tree-title-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #6b6878; margin-bottom: 20px; font-weight: bold;}
.add-btn { color: #c9a96e; cursor: pointer; font-size: 13px; padding: 4px 6px; border-radius:4px;}
.add-btn:hover { background: #2a2a35;}

/* 质检卡片 (右侧栏专属) */
.qa-card { background: #1a1a24; border: 1px solid #2a2a35; border-radius: 8px; padding: 12px; margin-bottom: 15px;}
.qa-title { font-size: 13px; font-weight: 600; color: #f0ebe0; margin-bottom: 8px;}
.qa-status { font-size: 12px; color: #a09898; background: #0f0f13; padding: 8px; border-radius: 4px; line-height: 1.4;}

/* 左侧目录树节点 */
.tree-node-container { margin-bottom: 10px; border-left: 1px solid #2a2a35; padding-left: 12px; margin-left: 8px; position: relative; }
.tree-node-container::before { content: ''; position: absolute; left: 0; top: 18px; width: 10px; height: 1px; background: #2a2a35; }
.event-card { background: #14141a; border: 1px solid #2a2a35; border-radius: 8px; padding: 12px 10px; transition: 0.2s; position: relative; cursor: pointer;}
.event-card:hover { border-color: #c9a96e66; }
.event-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;}
.event-name { font-size: 13px; font-weight: 600; color: #f0ebe0; }
.event-status { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: #2a2a35; color: #a09898; }
.event-status.done { background: #1a2e1a; color: #7ec97e; }
.event-desc { font-size: 11px; color: #6b6878; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4;}
.card-actions { display: flex; gap: 6px; }
.btn-sm { flex: 1; background: #0f0f13; border: 1px solid #3a3a4a; color: #a09898; border-radius: 6px; font-size: 11px; padding: 6px 0; cursor: pointer; transition: 0.15s; text-align: center; }
.btn-sm:hover { color: #c9a96e; border-color: #c9a96e; background: #1a1a24; }

/* 中间工作区及坐标 */
.workspace { flex: 1; position: relative; background: #0f0f13; overflow-y: auto; overflow-x: hidden; }
.timeline-container { position: relative; width: 100%; min-height: 1000px; padding: 80px 0 150px 0; }
.center-axis { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px dashed rgba(255,255,255,0.08); transform: translateX(-50%); z-index: 0; }
.axis-title { position: absolute; left: 50%; top: 20px; transform: translateX(-50%); background: #0f0f13; padding: 6px 16px; color: #6b6878; font-size: 12px; font-weight: bold; border: 1px solid #2a2a35; border-radius: 20px; z-index: 2;}
#svg-layer, #nodes-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

.node { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; pointer-events: auto; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.6); border: 2px solid; transition: 0.2s; }
.node:hover { transform: translate(-50%, -50%) scale(1.15); box-shadow: 0 0 15px #c9a96e; }
.node-origin { background: #e8e4dc !important; border: none !important; width: 10px !important; height: 10px !important; pointer-events: none; box-shadow: 0 0 10px #c9a96e !important;}

.label-box { position: absolute; width: 160px; white-space: normal; word-wrap: break-word; background: rgba(20,20,26,0.95); border: 1px solid #2a2a35; padding: 8px 12px; border-radius: 8px; font-size: 12px; pointer-events: none; backdrop-filter: blur(4px);}
.label-title { color: #f0ebe0; font-weight: bold; margin-bottom: 3px; font-size: 13px;}

/* --- 统一完美弹窗防遮挡体系 --- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999; align-items: center; justify-content: center; padding: 20px;}
.modal-overlay.open { display: flex; }
.modal-box { margin: auto; display: flex; flex-direction: column; background: #14141a; border: 1px solid #2a2a35; border-radius: 12px; width: 100%; max-width: 480px; max-height: 85vh; box-shadow: 0 12px 48px rgba(0,0,0,0.8); }
.modal-header { padding: 20px 24px 15px; border-bottom: 1px solid #2a2a35; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 600; color: #f0ebe0; display:flex; justify-content:space-between; align-items:center; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch;}
.modal-footer { padding: 15px 24px 20px; border-top: 1px solid #2a2a35; flex-shrink: 0; display: flex; gap: 12px; background: #14141a; border-radius: 0 0 12px 12px;}

.modal-field { margin-bottom: 18px; }
.modal-field label { display: block; font-size: 12px; color: #a09898; margin-bottom: 8px; font-weight: bold;}
.modal-field input, .modal-field textarea, .modal-field select { width: 100%; background: #0f0f13; border: 1px solid #2a2a35; border-radius: 6px; padding: 12px 14px; color: #e8e4dc; font-size: 13px; outline: none; transition: 0.2s;}
.modal-field input:focus, .modal-field textarea:focus { border-color: #c9a96e88; }
.modal-field textarea { min-height: 80px; resize: vertical; line-height: 1.6;}

.modal-btn { flex: 1; padding: 12px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: 0.15s; text-align: center; }
.btn-primary { background: #c9a96e; color: #0f0f13; }
.btn-primary:hover { background: #d4b87a; }
.btn-ghost { background: transparent; border: 1px solid #3a3a4a; color: #a09898; }
.btn-ghost:hover { background: #17171f; color: #e8e4dc; }
.btn-danger { background: rgba(224, 112, 112, 0.1); border: 1px solid rgba(224, 112, 112, 0.3); color: #e07070;}
.btn-danger:hover { background: rgba(224, 112, 112, 0.2); }

.ai-ctrl-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.btn-ai-run { flex: 1; background: #2e4e2e22; border: 1px solid #2e4e2e; color: #7ec97e; border-radius: 6px; padding: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s;}
.btn-ai-run:hover { background: #2e4e2e44; }
.btn-ai-run:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-eye { width: 44px; height: 44px; background: transparent; border: 1px solid #3a3a4a; border-radius: 6px; color: #a09898; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;}
.btn-eye:hover { color: #c9a96e; border-color: #c9a96e; }
.btn-manual-run { width: 100%; background: transparent; border: 1px dashed #6b6878; color: #a09898; border-radius: 6px; padding: 12px; font-size: 13px; cursor: pointer; transition: 0.2s;}
.btn-manual-run:hover { border-color: #c9a96e; color: #c9a96e; }

/* 🌟 数据管理特属框 */
.data-card { background: #0c0c10; border: 1px solid #2a2a35; border-radius: 8px; padding: 15px; margin-bottom: 12px;}
.data-card-title { font-size: 14px; font-weight: bold; color: #f0ebe0; margin-bottom: 8px; display: flex; align-items: center; gap: 8px;}
.data-card-desc { font-size: 12px; color: #6b6878; margin-bottom: 12px; line-height: 1.5;}

.toast { position: fixed; top: 20px; left: 50%; margin-left: -100px; width: 200px; text-align: center; background: #c9a96e; color: #000; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: bold; opacity: 0; pointer-events: none; transition: 0.3s; z-index: 3000; box-shadow: 0 4px 15px rgba(0,0,0,0.5);}
.toast.show { opacity: 1; transform: translateY(15px); }

/* --- 提示词引擎样式 --- */
.tmpl-section-title { font-size: 13px; color: #f0ebe0; font-weight: bold; border-left: 3px solid #36cfc9; padding-left: 8px; margin: 0 0 10px; }
.tmpl-textarea { min-height: 90px !important; font-size: 12px !important; color: #a09898 !important; font-family: monospace; background: #14141a !important; line-height: 1.5 !important;}
.hint-badge { display: inline-block; background: #2a2a35; border: 1px solid #3a3a4a; color: #c9a96e; padding: 3px 6px; border-radius: 4px; font-size: 11px; margin: 2px 4px 4px 0;}

/* --- Diff 差异采纳面板 --- */
.diff-card { background: #14141a; border: 1px solid #3a3a4a; border-radius: 8px; margin-bottom: 15px; overflow: hidden; transition: 0.2s;}
.diff-card:hover { border-color: #36cfc9; }
.diff-header { background: rgba(54, 207, 201, 0.08); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(54, 207, 201, 0.2); }
.diff-title { font-size: 13px; font-weight: bold; color: #36cfc9; }
.diff-body { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
@media (min-width: 600px) { .diff-row { display: flex; gap: 16px; } }
@media (max-width: 599px) { .diff-row { display: flex; flex-direction: column; gap: 12px; } }
.diff-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.diff-label { font-size: 11px; color: #6b6878; font-weight:bold;}
.diff-old-text { background: #0c0c10; padding: 10px; border-radius: 6px; font-size: 12px; color: #a09898; min-height: 80px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; border: 1px dashed #2a2a35;}

@media (max-width: 768px) {
  .btn-mobile-menu { display: block; }
  .left-sidebar { position: fixed; left: -100%; top: 52px; height: calc(100vh - 52px); transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 5px 0 15px rgba(0,0,0,0.5);}
  .left-sidebar.open { left: 0; }
  .right-sidebar { position: fixed; right: -100%; top: 52px; height: calc(100vh - 52px); transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: -5px 0 15px rgba(0,0,0,0.5);}
  .right-sidebar.open { right: 0; }
  .mobile-overlay.open { display: block; }
  .topnav .nav-btn span { display: none; }
  .modal-overlay { padding: 16px; align-items: center;}
  .modal-box { max-width: 100%; width: 100%; max-height: 92vh; border-radius: 12px;}
  .label-box { transform: scale(0.85); transform-origin: left center;}
}
