/* ===== 基础 ===== */
:root {
  --bg: #ffffff;
  --bg-soft: #f8f8fa;
  --side-bg: #f5f5f8;
  --result-bg: #fcfcfd;
  --border: #e8e8ee;
  --text: #1f2330;
  --soft: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --green: #10b981;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); height: 100vh; overflow: hidden; -webkit-font-smoothing: antialiased;
}
.app { display: flex; height: 100vh; }

/* ===== 左栏 ===== */
.sidebar {
  width: 250px; background: var(--side-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: transform .25s; flex-shrink: 0;
}
.sidebar.collapsed { transform: translateX(-100%); margin-left: -250px; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 12px; }
.logo { font-size: 26px; }
.brand { font-weight: 700; font-size: 17px; }
.new-task-btn {
  margin: 4px 12px 14px; padding: 11px; background: var(--accent); color: #fff;
  border: none; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.new-task-btn:hover { background: #4338ca; }
.task-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.task-item {
  padding: 11px 12px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
  color: var(--soft); margin-bottom: 3px; display: flex; gap: 8px; align-items: center;
}
.task-item:hover { background: rgba(0,0,0,.04); }
.task-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.task-item .t-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item .t-del { opacity: 0; font-size: 14px; }
.task-item:hover .t-del { opacity: 1; }
.side-foot { padding: 12px; border-top: 1px solid var(--border); }
.side-link {
  width: 100%; padding: 9px; text-align: left; border: none; background: transparent;
  cursor: pointer; font-size: 14px; color: var(--soft); border-radius: 8px;
}
.side-link:hover { background: rgba(0,0,0,.05); }
.side-note { font-size: 11px; color: #a1a1aa; margin-top: 8px; padding: 0 9px; line-height: 1.5; }

/* ===== 中栏 ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; gap: 12px; padding: 0 18px; flex-shrink: 0;
}
.menu-btn { display: none; }
.task-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-badge {
  padding: 4px 11px; background: #fef3c7; color: #b45309;
  border-radius: 16px; font-size: 11.5px; font-weight: 600;
}
.mode-badge.real { background: #d1fae5; color: #047857; }
.top-actions { margin-left: auto; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; font-size: 17px;
  color: var(--soft); width: 34px; height: 34px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }

/* 执行轨迹 */
.stream-area { flex: 1; overflow-y: auto; padding: 24px 0; }
.welcome { max-width: 700px; margin: 0 auto; padding: 50px 24px 20px; text-align: center; }
.welcome-logo { font-size: 50px; margin-bottom: 14px; }
.welcome h1 { font-size: 23px; margin-bottom: 8px; }
.welcome p { color: var(--soft); font-size: 14px; }
.example-tasks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 28px 0; }
.example-chip {
  padding: 13px 14px; border: 1px solid var(--border); border-radius: 11px;
  font-size: 13px; cursor: pointer; text-align: left; background: #fff; transition: all .15s;
}
.example-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.demo-notice {
  display: flex; gap: 9px; align-items: flex-start; text-align: left;
  background: #fff8e6; border: 1px solid #ffe9a8; padding: 12px 15px;
  border-radius: 11px; font-size: 12.5px; color: #8a6d1f; line-height: 1.6;
}
.demo-notice.hidden { display: none; }
.demo-notice .dot { width: 8px; height: 8px; background: var(--amber); border-radius: 50%; flex-shrink: 0; margin-top: 5px; }

.trace { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.trace.hidden { display: none; }
.step { margin-bottom: 18px; animation: fadein .3s; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.step-head {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  color: var(--soft); font-weight: 600; margin-bottom: 8px;
}
.step-head .num {
  width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft);
  color: var(--accent); display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.step-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px;
  background: #fff; font-size: 13.5px; line-height: 1.7;
}
.step-card.thought { background: #faf9ff; border-color: #e6e3ff; }
.step-card.tool_call { background: #f0f9ff; border-color: #cfe8ff; }
.step-card.tool_result { background: #f0fdf6; border-color: #c6f0d9; }
.step-card.final { background: #fff; border-color: var(--border); }
.step-card.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.tool-name {
  display: inline-flex; align-items: center; gap: 6px; font-family: monospace;
  background: #dbeafe; color: #1d4ed8; padding: 3px 9px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600;
}
.tool-args {
  margin-top: 8px; background: #0d1117; color: #e6edf3; padding: 10px 12px;
  border-radius: 8px; font-family: monospace; font-size: 12px; white-space: pre-wrap;
  word-break: break-all;
}
.tool-result-text {
  margin-top: 6px; font-family: monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; color: #065f46;
  max-height: 200px; overflow-y: auto;
}
.step-card p { margin: 0 0 8px; }
.step-card p:last-child { margin-bottom: 0; }
.step-card pre {
  background: #0d1117; color: #e6edf3; padding: 12px; border-radius: 8px;
  overflow-x: auto; margin: 8px 0;
}
.step-card code {
  background: rgba(0,0,0,.06); padding: 2px 5px; border-radius: 4px;
  font-family: monospace; font-size: 12.5px;
}
.step-card pre code { background: none; }
.step-card ul, .step-card ol { padding-left: 20px; margin: 8px 0; }
.cursor-blink::after { content: "▋"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* 输入区 */
.composer-wrap { padding: 12px 24px 16px; flex-shrink: 0; }
.composer {
  max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px;
  border: 1px solid var(--border); border-radius: 15px; padding: 8px 8px 8px 15px;
  background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.05);
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: none; outline: none; resize: none; font-family: inherit;
  font-size: 14px; line-height: 1.5; max-height: 150px; padding: 6px 0;
  background: transparent; color: var(--text);
}
.run-btn {
  padding: 0 16px; height: 38px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
}
.run-btn:hover { background: #4338ca; }
.run-btn:disabled { background: #c7c7d1; cursor: not-allowed; }
.run-btn.stop { background: #ef4444; }
.composer-note { text-align: center; font-size: 11.5px; color: #a1a1aa; margin-top: 7px; }

/* ===== 右栏：产物 ===== */
.result-panel {
  width: 290px; background: var(--result-bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--border);
}
.result-head h3 { font-size: 14px; }
.file-list { padding: 8px; max-height: 40%; overflow-y: auto; }
.file-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.file-item:hover { background: var(--accent-soft); }
.file-item .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .f-size { font-size: 11px; color: #a1a1aa; }
.file-empty { padding: 20px; text-align: center; color: #a1a1aa; font-size: 12.5px; }
.file-preview {
  flex: 1; overflow: auto; border-top: 1px solid var(--border);
  padding: 14px; font-size: 12.5px; line-height: 1.6;
}
.preview-empty { color: #a1a1aa; text-align: center; margin-top: 30px; }
.preview-title { font-weight: 600; margin-bottom: 10px; font-size: 13px; }
.file-preview pre {
  background: #0d1117; color: #e6edf3; padding: 12px; border-radius: 8px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px;
}

/* ===== 设置面板 ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0;
  pointer-events: none; transition: opacity .2s; z-index: 20;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.settings-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 400px; max-width: 92vw;
  background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,.12);
  transform: translateX(100%); transition: transform .25s; z-index: 21;
  display: flex; flex-direction: column;
}
.settings-panel.show { transform: translateX(0); }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.settings-head h2 { font-size: 18px; }
.settings-body { flex: 1; overflow-y: auto; padding: 20px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; font-family: inherit; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--soft); margin-top: 6px; line-height: 1.5; }
.model-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.model-chip {
  padding: 5px 10px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 16px; font-size: 12px; cursor: pointer;
}
.model-chip:hover, .model-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.settings-foot {
  padding: 14px 20px; border-top: 1px solid var(--border); display: flex;
  gap: 10px; justify-content: flex-end;
}
.btn-primary, .btn-ghost {
  padding: 10px 20px; border-radius: 9px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn-primary { background: var(--accent); color: #fff; border: none; }
.btn-ghost { background: #fff; color: var(--soft); border: 1px solid var(--border); }

@media (max-width: 1000px) {
  .result-panel { display: none; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 15; height: 100%; }
  .menu-btn { display: inline-flex; }
  .example-tasks { grid-template-columns: 1fr; }
}

/* ===== 扩展模块抽屉 ===== */
.modules-btn {
  padding: 7px 13px; background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.modules-btn:hover { background: #dfe5ff; }
.modules-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0;
  pointer-events: none; transition: opacity .25s; z-index: 30;
}
.modules-overlay.show { opacity: 1; pointer-events: auto; }
.modules-drawer {
  position: fixed; top: 0; left: 50%; transform: translate(-50%, -100%);
  width: 880px; max-width: 96vw; height: 92vh; margin-top: 2vh;
  background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  z-index: 31; display: flex; flex-direction: column; transition: transform .3s;
}
.modules-drawer.show { transform: translate(-50%, 0); }
.modules-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.modules-head h2 { font-size: 18px; }
.modules-tabs {
  display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
}
.mtab {
  padding: 10px 14px; border: none; background: transparent; cursor: pointer;
  font-size: 13px; color: var(--soft); border-bottom: 2px solid transparent; white-space: nowrap;
}
.mtab:hover { color: var(--accent); }
.mtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.modules-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.mpanel { display: none; }
.mpanel.active { display: block; animation: fadein .25s; }
.panel-desc { font-size: 13px; color: var(--soft); margin-bottom: 16px; line-height: 1.6; }
.panel-form { margin-bottom: 16px; }
.panel-form label { display: block; font-size: 12.5px; font-weight: 600; margin: 10px 0 6px; }
.panel-form input, .panel-form textarea, .mm-card input, .mm-card textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none; margin-bottom: 6px;
}
.panel-form input:focus, .panel-form textarea:focus { border-color: var(--accent); }
.form-row { display: flex; gap: 8px; margin: 6px 0; }
.form-row > * { flex: 1; }
.panel-output {
  margin-top: 14px; background: #f8f8fb; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto;
  display: none;
}
.panel-output.show { display: block; }
.skill-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.skill-card {
  border: 1px solid var(--border); border-radius: 11px; padding: 13px;
  cursor: pointer; transition: all .15s; background: #fff;
}
.skill-card:hover { border-color: var(--accent); }
.skill-card.active { border-color: var(--accent); background: var(--accent-soft); }
.skill-card .sc-icon { font-size: 22px; }
.skill-card .sc-name { font-weight: 600; font-size: 13.5px; margin: 6px 0 4px; }
.skill-card .sc-desc { font-size: 11.5px; color: var(--soft); line-height: 1.5; }
.doc-list { margin: 12px 0; }
.doc-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 8px;
  background: var(--bg-soft); margin-bottom: 5px; font-size: 12.5px;
}
.doc-item .d-name { flex: 1; }
.doc-item .d-del { cursor: pointer; color: var(--soft); }
.mm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mm-card { border: 1px solid var(--border); border-radius: 12px; padding: 15px; }
.mm-card h4 { font-size: 14px; margin-bottom: 10px; }
.job-list { margin: 12px 0; }
.job-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; margin-bottom: 7px; font-size: 12.5px;
}
.job-item .j-task { flex: 1; }
.job-item .j-meta { color: var(--soft); font-size: 11px; }
.mini-action {
  padding: 4px 9px; font-size: 11.5px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; cursor: pointer;
}
.mini-action:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 720px) {
  .skill-grid, .mm-grid { grid-template-columns: 1fr 1fr; }
  .modules-btn { font-size: 0; padding: 7px 10px; }
  .modules-btn::after { content: "🧩"; font-size: 14px; }
}

/* ===== 顶栏用户徽章 ===== */
.user-badge {
  font-size: 12.5px; color: var(--soft); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 16px; padding: 5px 12px;
  white-space: nowrap; user-select: none;
}

/* ===== 登录门禁（全屏） ===== */
.auth-gate {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #eef2ff, #f8f8fa 60%);
}
.auth-gate.show { display: flex; }
.gate-card {
  width: 380px; max-width: 92vw; background: #fff; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(79,70,229,.12); padding: 36px 32px 24px;
  text-align: center;
}
.gate-logo { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.gate-title { font-size: 24px; font-weight: 800; letter-spacing: .3px; }
.gate-sub { font-size: 13px; color: var(--soft); margin: 6px 0 22px; }
.gate-tabs {
  display: flex; background: var(--bg-soft); border-radius: 10px; padding: 4px; margin-bottom: 18px;
}
.gate-tab {
  flex: 1; padding: 9px; border: none; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--soft); border-radius: 7px;
}
.gate-tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.gate-msg { min-height: 18px; font-size: 12.5px; color: #dc2626; margin-bottom: 8px; }
.gate-msg.ok { color: var(--green); }
.gate-form { display: flex; flex-direction: column; gap: 11px; }
.gate-form input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; font-family: inherit; outline: none;
}
.gate-form input:focus { border-color: var(--accent); }
.gate-submit { width: 100%; margin-top: 4px; }
.gate-foot { font-size: 11px; color: #b0b0ba; margin-top: 20px; }

/* ===== 计费中心 ===== */
.credits-badge {
  font-size: 12.5px; color: var(--accent); background: var(--accent-soft);
  border: 1px solid #dbe3ff; border-radius: 16px; padding: 5px 12px; white-space: nowrap;
}
.credits-badge b { font-weight: 700; }
.recharge-btn {
  font-size: 12.5px; color: #fff; background: var(--accent); border: none;
  border-radius: 16px; padding: 6px 14px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.recharge-btn:hover { opacity: .9; }
.bill-account {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px;
}
.bill-stat {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; text-align: center;
}
.bill-stat span { display: block; font-size: 11px; color: var(--soft); margin-bottom: 4px; }
.bill-stat b { font-size: 16px; }
.tier-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.tier {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 4px; text-align: center;
  cursor: pointer; background: #fff; transition: all .15s;
}
.tier:hover { border-color: var(--accent); }
.tier.active { border-color: var(--accent); background: var(--accent-soft); }
.tier b { display: block; font-size: 15px; color: var(--text); }
.tier span { display: block; font-size: 10.5px; color: var(--soft); margin-top: 2px; }
.bill-subtitle { font-size: 13.5px; margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
#billAccount .bill-stat, #profitCards.bill-account { grid-column: auto; }
@media (max-width: 720px) { .tier-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---- 推广中心 / 技能市场（本次新增）---- */
.gate-bonus {
  background: linear-gradient(90deg, rgba(250,204,21,.14), rgba(99,102,241,.14));
  border: 1px solid rgba(250,204,21,.35); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; color: #fbbf24; text-align: center;
}
.gate-bonus b { color: #fde047; font-size: 14px; }
#refCode { color: #22d3ee; font-size: 17px; }
#refRecords .doc-item { border-left: 3px solid #22d3ee; }
.skill-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.skill-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  background: var(--bg-soft); display: flex; flex-direction: column; gap: 7px;
}
.skill-name { font-size: 14.5px; font-weight: 600; }
.skill-desc { font-size: 12px; color: var(--soft); flex: 1; min-height: 34px; }
.skill-cost { font-size: 11.5px; color: #f59e0b; }
.skill-use { padding: 7px; font-size: 12.5px; }
@media (max-width: 720px) { .skill-grid { grid-template-columns: 1fr; } }

/* ===== 技能工坊 (skillmarket) ===== */
.sm-sections { display: flex; gap: 8px; margin: 10px 0; }
.sm-tab { padding: 6px 14px; border: 1px solid var(--border, #e4e4e7); border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; }
.sm-tab.active { background: var(--accent, #6366f1); color: #fff; border-color: transparent; }
.sm-sec { display: none; }
.sm-sec.active { display: block; }
.sm-runbox { margin-top: 12px; border-top: 1px dashed var(--border, #e4e4e7); padding-top: 8px; }
.skill-meta { font-size: 11px; color: #a1a1aa; margin: 4px 0; }
.sm-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sm-cat { padding: 4px 12px; border: 1px solid var(--border, #e4e4e7); border-radius: 999px; background: transparent; cursor: pointer; font-size: 12.5px; }
.sm-cat.active { background: var(--accent, #6366f1); color: #fff; border-color: transparent; }
.sm-cat-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #eef2ff; color: #4f46e5; font-size: 11px; margin-right: 4px; vertical-align: middle; }

/* ===== 积分挂单市场 (orderbook) ===== */
.ob-sec { display: none; }
.ob-sec.active { display: block; }
.ob-unit { font-size: 11px; color: #a1a1aa; }
