/* ops-chat — 暗色优先，聊天式布局 */
:root {
  --bg: #0e1012;
  --surface: #16191c;
  --surface-2: #1c2024;
  --border: #262b30;
  --border-strong: #363d44;
  --text: #e9ecef;
  --muted: #98a1aa;
  --faint: #6b757e;
  --accent: #4d9dff;
  --ok: #3fbf87;
  --warn: #e2a33c;
  --danger: #e05c5c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
html[data-theme="light"] {
  --bg: #f6f6f4; --surface: #fff; --surface-2: #f1f1ef;
  --border: #e2e2de; --border-strong: #cfcfc9;
  --text: #15181c; --muted: #5f6871; --faint: #8b949c;
  --accent: #1f6fe0; --ok: #1e8f5f; --warn: #a5701a; --danger: #c33d3d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
button { cursor: pointer; }
.btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: transparent; }
.btn--sm { padding: 5px 10px; font-size: 12px; }

/* ---------------------------------------------------------------- 布局 */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex: none;
}
.bar__left { display: flex; align-items: center; gap: 9px; margin-right: auto; }
.bar__title { font-weight: 600; font-size: 14px; }
.bar__model {
  font-size: 11px; color: var(--faint); font-family: var(--mono);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}
.bar__right { display: flex; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.is-live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.is-busy { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.thread {
  flex: 1; overflow-y: auto; padding: 26px 18px 10px;
  scroll-behavior: auto;
}
.thread > * { max-width: 820px; margin-left: auto; margin-right: auto; }

/* ---------------------------------------------------------------- 欢迎 */
.welcome { padding: 40px 4px 20px; }
.welcome h1 { font-size: 20px; font-weight: 600; margin: 0 0 8px; letter-spacing: -.01em; }
.welcome p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  font-size: 12.5px; padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.chip-btn:hover { border-color: var(--border-strong); color: var(--text); }

/* ---------------------------------------------------------------- 消息 */
.turn { margin-bottom: 26px; }

.msg-user {
  display: flex; justify-content: flex-end; margin-bottom: 14px;
}
.msg-user__bubble {
  background: var(--accent); color: #fff; padding: 9px 14px;
  border-radius: 14px 14px 3px 14px; max-width: 78%;
  white-space: pre-wrap; word-break: break-word;
}

.msg-ai { display: flex; flex-direction: column; gap: 10px; }

/* 思考块 */
.think {
  border-left: 2px solid var(--border-strong); padding: 2px 0 2px 12px;
  color: var(--faint); font-size: 12.5px;
}
.think__head {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  color: var(--muted); font-size: 12px; user-select: none;
  background: none; border: none; padding: 0; margin-bottom: 2px;
}
.think__head:hover { color: var(--text); }
.think__body {
  white-space: pre-wrap; word-break: break-word;
  max-height: 220px; overflow-y: auto; line-height: 1.6;
}
.think.is-collapsed .think__body { display: none; }

/* 工具卡片 */
.tool {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
.tool__head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 12.5px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tool__name { font-family: var(--mono); font-weight: 500; color: var(--text); }
.tool__state { margin-left: auto; font-size: 11px; color: var(--faint); }
.tool__state.is-run { color: var(--warn); }
.tool__state.is-ok { color: var(--ok); }
.tool__state.is-err { color: var(--danger); }
.tool__body { padding: 0; }
.tool__args {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  padding: 8px 12px; white-space: pre-wrap; word-break: break-all;
  border-bottom: 1px solid var(--border);
}
.tool__args:empty { display: none; }
.tool__out {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  padding: 9px 12px; white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto; margin: 0;
}

/* 正文 */
.answer { white-space: pre-wrap; word-break: break-word; }
.answer code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--surface-2); padding: 1px 5px; border-radius: 5px;
}
.answer pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 14px; overflow-x: auto; margin: 10px 0;
}
.answer pre code { background: none; padding: 0; }

.cursor::after {
  content: "▍"; color: var(--accent);
  animation: blink 1s steps(2) infinite; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.meta {
  font-size: 11px; color: var(--faint); font-family: var(--mono);
  display: flex; gap: 14px; flex-wrap: wrap;
}
.err-box {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger); border-radius: 9px; padding: 10px 13px; font-size: 13px;
}

/* ---------------------------------------------------------------- 输入 */
.jump {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 7px 14px; font-size: 12px; color: var(--muted);
  z-index: 20;
}
.composer {
  flex: none; display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 18px 18px; border-top: 1px solid var(--border);
  background: var(--bg);
}
.composer textarea {
  flex: 1; resize: none; max-height: 180px; min-height: 42px;
  border-radius: 12px; padding: 11px 14px; line-height: 1.5;
}
.composer .btn { height: 42px; padding: 0 20px; border-radius: 12px; }

/* ---------------------------------------------------------------- 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 30px 26px;
}
.login-card h1 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.login-card .sub { font-size: 12.5px; color: var(--muted); margin: 0 0 20px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input { width: 100%; }

@media (max-width: 640px) {
  .thread { padding: 16px 12px 6px; }
  .composer { padding: 10px 12px 14px; }
  .msg-user__bubble { max-width: 88%; }
}
