/* ==========================================================================
   theme.css —— 设计变量与基础样式（淡蓝主题）
   ========================================================================== */

:root {
  /* 主色阶：淡蓝 */
  --blue-50: #f5f9ff;
  --blue-100: #eaf2ff;
  --blue-150: #e2eeff;
  --blue-200: #d3e4ff;
  --blue-300: #b7d3ff;
  --blue-400: #7fb0ff;
  --blue-500: #4d8dff;
  --blue-600: #2f6fe4;
  --blue-700: #2459bd;

  /* 中性色 */
  --text: #16263c;
  --text-soft: #2c3f57;
  --muted: #6b7f99;
  --muted-2: #8fa2ba;
  --line: #e2ebf9;
  --line-soft: #edf3fc;
  --surface: #ffffff;
  --surface-2: #f7fafe;
  --bg: #f3f8ff;

  /* 语义色 */
  --danger: #e35b5b;
  --danger-soft: #fdeeee;
  --ok: #2f9e6f;
  --warn: #c98527;

  /* 圆角与阴影 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(31, 68, 128, .06);
  --shadow: 0 6px 20px rgba(43, 92, 170, .09);
  --shadow-lg: 0 18px 50px rgba(36, 78, 148, .13);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "JetBrains Mono", "Cascadia Code", "Courier New", monospace;

  --sidebar-w: 268px;
  --content-max: 800px;
  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--font-mono); }

::selection { background: var(--blue-200); color: var(--text); }

/* 滚动条 */
.scrollable,
.chat-scroll,
.conversation-nav {
  scrollbar-width: thin;
  scrollbar-color: var(--blue-200) transparent;
}
.scrollable::-webkit-scrollbar,
.chat-scroll::-webkit-scrollbar,
.conversation-nav::-webkit-scrollbar { width: 8px; }
.scrollable::-webkit-scrollbar-thumb,
.chat-scroll::-webkit-scrollbar-thumb,
.conversation-nav::-webkit-scrollbar-thumb {
  background: var(--blue-200);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.scrollable::-webkit-scrollbar-thumb:hover,
.chat-scroll::-webkit-scrollbar-thumb:hover { background: var(--blue-300); background-clip: content-box; }

/* 通用按钮 */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--blue-100); color: var(--blue-700); }
.icon-btn:active { transform: scale(.96); }

.primary-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(61, 126, 240, .28);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}
.primary-btn:hover { filter: brightness(1.04); box-shadow: 0 10px 26px rgba(61, 126, 240, .34); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn[disabled] { cursor: progress; filter: saturate(.75) brightness(.98); }

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.is-loading .btn-spinner { display: inline-block; }
.is-loading .btn-label { opacity: .72; }

@keyframes spin { to { transform: rotate(360deg); } }

/* 提示条 */
.toast-host {
  position: fixed;
  z-index: 90;
  top: 22px;
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  min-width: 160px;
  max-width: 76vw;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(22, 38, 60, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in .22s ease-out;
}
.toast.is-error { background: rgba(199, 62, 62, .95); }
.toast.is-ok { background: rgba(32, 132, 92, .95); }
.toast.is-out { animation: toast-out .2s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* 通用弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 45, 78, .28);
  backdrop-filter: blur(3px);
}
.modal {
  width: min(400px, 100%);
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease-out;
}
.modal h3 { font-size: 16px; }
.modal p { margin-top: 8px; color: var(--muted); font-size: 13.5px; word-break: break-word; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.ghost-action,
.danger-action {
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.ghost-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
}
.ghost-action:hover { background: var(--surface-2); }
.danger-action {
  border: 1px solid transparent;
  background: var(--danger);
  color: #fff;
}
.danger-action:hover { filter: brightness(1.05); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.hidden, [hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
