* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b0f1a;
  --panel: rgba(255,255,255,.05);
  --panel-2: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.12);
  --text: #e5e7eb;
  --muted: rgba(255,255,255,.5);
  --accent: linear-gradient(90deg, #60a5fa, #a78bfa);
  --accent-solid: #7c6cf0;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,15,26,.9);
  backdrop-filter: blur(10px);
}
.logo {
  font-size: 18px; font-weight: 800;
  background: var(--accent);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar nav { display: flex; gap: 8px; flex: 1; }
.tab {
  padding: 8px 18px; border: none; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer; transition: all .2s;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: var(--panel-2); color: #fff; }
.storage-badge {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
}

/* ---------- 页面布局 ---------- */
.page { display: none; flex: 1; min-height: 0; }
.page.active { display: flex; }

/* ---------- 侧栏 ---------- */
.session-panel, .wf-panel {
  width: 240px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.new-session {
  background: var(--accent);
  color: #fff; border: none; padding: 10px;
  border-radius: 10px; font-weight: 700; cursor: pointer;
  font-size: 14px;
}
.new-session:hover { filter: brightness(1.15); }
.session-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.session-item {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font-size: 13px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid transparent;
}
.session-item:hover { background: var(--panel-2); }
.session-item.active { background: var(--panel-2); color: #fff; border-color: var(--border); }
.session-item .del { opacity: 0; border: none; background: none; color: #f87171; cursor: pointer; font-size: 14px; }
.session-item:hover .del { opacity: 1; }
.session-item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 聊天区 ---------- */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 10px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: flex-end; }
.model-select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px;
}
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.empty-hint { margin: auto; text-align: center; color: var(--muted); }
.empty-hint h2 { font-size: 20px; margin-bottom: 8px; background: var(--accent); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.empty-hint p { font-size: 13px; }

.msg { display: flex; gap: 12px; max-width: 860px; width: 100%; margin: 0 auto; }
.msg .avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.msg.user .avatar { background: #1e3a8a; }
.msg.assistant .avatar { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.msg .bubble {
  padding: 12px 16px; border-radius: 12px; line-height: 1.7;
  font-size: 14px; white-space: pre-wrap; word-break: break-word;
  flex: 1; min-width: 0;
}
.msg.user .bubble { background: #1e3a8a; }
.msg.assistant .bubble { background: var(--panel-2); border: 1px solid var(--border); }
.msg .bubble.error { color: #f87171; }
.cursor { display: inline-block; width: 7px; height: 15px; background: #7dd3fc; margin-left: 2px; animation: blink 1s infinite; vertical-align: text-bottom; }
@keyframes blink { 50% { opacity: 0; } }

.input-bar {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 12px; max-width: 908px; width: 100%; margin: 0 auto;
}
#chatInput {
  flex: 1; resize: none; max-height: 140px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; color: var(--text);
  font-size: 14px; font-family: inherit; outline: none;
}
#chatInput:focus { border-color: #7c6cf0; }
.send-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 0 26px; border-radius: 12px; font-weight: 700; cursor: pointer;
}
.send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 工作流编辑器 ---------- */
.wf-editor { flex: 1; overflow-y: auto; padding: 24px; }
.wf-form { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.wf-form .row { display: flex; gap: 12px; }
.wf-form .row > * { flex: 1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; color: var(--text);
  font-size: 14px; font-family: inherit; outline: none;
}
.field textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #7c6cf0; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .hint code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; color: #a5f3fc; }

.vars-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.wf-actions { display: flex; gap: 10px; }
.btn {
  border: none; border-radius: 10px; padding: 10px 22px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: rgba(248,113,113,.15); color: #f87171; }
.run-result {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; background: rgba(0,0,0,.3);
  font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  min-height: 60px;
}
.run-result .label { font-size: 12px; color: #fde047; font-family: ui-monospace, monospace; display: block; margin-bottom: 8px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
