/* VibeCoding Gateway Web — 样式 (复刻 app 企业蓝风格) */
:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-container: #e0e7ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --on-surface: #1e293b;
  --on-surface-2: #64748b;
  --error: #ef4444;
  --error-container: #fee2e2;
  --on-error: #ffffff;
  --on-error-container: #991b1b;
  --tertiary-container: #ede9fe;
  --secondary-container: #e0e7ff;
  --outline: #cbd5e1;
  --ok: #22c55e;
  --warn: #f59e0b;
  --topbar-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #334155;
    --surface-3: #475569;
    --on-surface: #f1f5f9;
    --on-surface-2: #94a3b8;
    --primary-container: #1e3a8a;
    --secondary-container: #312e81;
    --tertiary-container: #4c1d95;
    --outline: #475569;
    --error-container: #7f1d1d;
    --on-error-container: #fecaca;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--on-surface);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---- 顶栏 ---- */
#topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  position: relative; z-index: 10;
}
#title-area { flex: 1; min-width: 0; }
#title-main { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#title-sub { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  background: none; border: none; color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255,255,255,.2); }
#back-btn { font-size: 30px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.disconnected { background: var(--error); }
.dot.connecting, .dot.connected { background: var(--warn); }
.dot.authed { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ---- 主区域 ---- */
#app { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- 通用列表 ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--surface);
  border-bottom: 1px solid var(--surface-2);
  cursor: pointer; min-width: 0;
}
.list-item:active { background: var(--surface-2); }
.list-item .li-leading { flex-shrink: 0; width: 24px; display: flex; justify-content: center; }
.list-item .li-text { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-sub { font-size: 13px; color: var(--on-surface-2); margin-top: 2px; white-space: pre-line; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-trail { flex-shrink: 0; color: var(--on-surface-2); font-size: 20px; }
.list-item.offline { opacity: .5; }
.icon { font-size: 24px; }
.icon-sm { font-size: 18px; }
.muted { color: var(--on-surface-2); }

/* loading / empty / error 占位 */
.center-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; text-align: center; color: var(--on-surface-2); gap: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--surface-3); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 卡片 (顶部新建对话等) */
.card { margin: 12px; border-radius: 12px; background: var(--surface); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card .list-item { border-bottom: none; }

/* Tab */
.tabs { display: flex; background: var(--primary); color: #fff; }
.tab { flex: 1; padding: 12px; text-align: center; font-size: 14px; font-weight: 500; cursor: pointer; border-bottom: 3px solid transparent; opacity: .7; }
.tab.active { opacity: 1; border-bottom-color: #fff; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: 18px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; font-size: 28px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
.fab:active { transform: scale(.95); }

/* ---- 聊天 ---- */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 8px 4px 80px; }
.bubble { max-width: 85%; margin: 4px 8px; padding: 10px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--primary-container); margin-left: auto; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); }
.bubble-row { display: flex; flex-direction: column; }
.bubble-row.user { align-items: flex-end; }
.bubble-row.assistant { align-items: flex-start; }

.part-thinking { margin: 6px 0; padding: 8px; background: var(--surface); border: 1px solid var(--outline); border-radius: 8px; font-size: 12px; color: var(--on-surface-2); font-style: italic; }
.part-tool { margin: 4px 0; padding: 6px 8px; background: var(--tertiary-container); border-radius: 6px; font-family: monospace; font-size: 12px; }
.part-tool.err { background: var(--error-container); }
.part-tool-output { font-size: 11px; color: var(--on-surface-2); margin-top: 4px; max-height: 90px; overflow: auto; white-space: pre-wrap; }

/* ask_question 选择卡片 */
.ask-card { margin: 4px 0; padding: 10px; background: var(--secondary-container); border: 1px solid var(--outline); border-radius: 10px; }
.ask-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.ask-badge { background: var(--primary); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: auto; }
.ask-q-header { font-size: 13px; font-weight: 600; margin: 8px 0 4px; }
.ask-q-text { font-size: 12px; opacity: .8; margin-bottom: 4px; }
.ask-opt { background: var(--surface); border: 1px solid var(--outline); border-radius: 6px; padding: 6px 8px; margin-bottom: 4px; cursor: pointer; }
.ask-opt:active { background: var(--surface-2); }
.ask-opt-label { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.ask-opt-desc { font-size: 11px; color: var(--on-surface-2); margin-left: 20px; margin-top: 2px; }
.ask-answer { margin-top: 6px; padding: 6px; background: var(--surface); border-radius: 6px; font-size: 11px; color: var(--on-surface-2); }
.ask-custom-toggle { background: none; border: none; color: var(--primary); font-size: 12px; padding: 6px 0; cursor: pointer; }

/* 聊天底部输入栏 */
.chat-input-bar { flex-shrink: 0; padding: 8px; background: var(--surface); border-top: 1px solid var(--surface-3); display: flex; gap: 6px; align-items: flex-end; }
.chat-input { flex: 1; resize: none; max-height: 120px; min-height: 40px; padding: 9px 14px; border: 1px solid var(--outline); border-radius: 20px; font-size: 15px; font-family: inherit; background: var(--surface); color: var(--on-surface); outline: none; }
.chat-input:focus { border-color: var(--primary); }
.chat-send { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--primary); color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.chat-send:disabled { opacity: .4; }
.chat-mic { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--outline); background: var(--surface); color: var(--on-surface-2); font-size: 18px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.chat-mic.recording { background: var(--error); color: #fff; border-color: var(--error); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.6;} }
.chat-progress { height: 2px; background: var(--surface-3); }
.chat-progress .bar { height: 100%; background: var(--primary); width: 100%; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0%{margin-left:-40%;width:40%;} 50%{margin-left:30%;width:40%;} 100%{margin-left:100%;width:40%;} }
.chat-error { background: var(--error-container); color: var(--on-error-container); padding: 8px; font-size: 12px; }
.stop-btn { background: var(--error); color: var(--on-error); border: none; border-radius: 20px; padding: 8px 14px; font-size: 13px; cursor: pointer; }

/* ---- 设置页 ---- */
.form-section { padding: 16px; background: var(--surface); margin-top: 8px; }
.form-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--on-surface-2); font-weight: 600; }
.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 13px; margin-bottom: 4px; }
.form-field input { width: 100%; padding: 10px; border: 1px solid var(--outline); border-radius: 8px; font-size: 14px; background: var(--surface); color: var(--on-surface); }
.btn-filled { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.help-step { display: flex; gap: 10px; margin: 10px 0; font-size: 13px; }
.help-num { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }

/* toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 100; max-width: 90%; text-align: center; }
.crumb { padding: 8px 16px; font-family: monospace; font-size: 12px; color: var(--on-surface-2); background: var(--surface-2); word-break: break-all; }
.bread-actions { padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--surface-3); display: flex; gap: 8px; align-items: center; }
