:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e6e8ee;
  --text: #14161d;
  --muted: #737a8a;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

h1,
h2 {
  margin: 0;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* ------------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  background: #eef0f5;
  color: var(--text);
  transition: background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: #e5e8ef;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--text);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip:hover {
  border-color: #c9cede;
}

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  flex: none;
}

.avatar.tiny {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ 表单 */

input[type="text"],
textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ------------------------------------------------------------- 配置/起名页 */

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.setup {
  width: 100%;
  max-width: 460px;
  padding: 30px 28px 24px;
}

.setup p {
  margin: 0 0 16px;
  font-size: 14.5px;
}

.setup form {
  display: flex;
  gap: 8px;
}

.setup input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
}

.brand-big {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 14px;
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex: none;
}

.steps {
  margin: 0 0 18px;
  padding-left: 20px;
  font-size: 14px;
  color: #3d4351;
}

.steps li {
  margin-bottom: 6px;
}

.steps a {
  color: var(--accent);
}

.steps code,
.hint code {
  background: #f2f3f7;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}

.hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ 顶栏 */

.bar {
  flex: none;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.bar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand strong {
  font-size: 16px;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat {
  border: 1px solid var(--border);
  background: #fbfbfd;
  color: #3d4351;
  font: inherit;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.stat:hover {
  border-color: #c9cede;
}

.stat .dot {
  color: #c3c8d4;
  margin: 0 3px;
}

/* ------------------------------------------------------------------ 消息 */

.chat {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 22px 20px 8px;
}

.messages {
  max-width: 780px;
  margin: 0 auto;
}

.msg {
  display: flex;
  margin-bottom: 14px;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 15.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.typing {
  color: var(--muted);
}

.hello {
  text-align: center;
  padding: 16vh 20px 0;
}

.hello-emoji {
  font-size: 34px;
  margin-bottom: 10px;
}

.hello h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.hello p {
  margin: 0;
  font-size: 14px;
}

/* ---------------------------------------------------------------- 输入区 */

.composer {
  flex: none;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  padding: 12px 20px 14px;
}

.composer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 160px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15.5px;
}

.composer .send {
  height: 46px;
  padding: 0 22px;
  border-radius: 12px;
}

.composer-meta {
  max-width: 780px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------------------------------------------------------------- 用量面板 */

.usage-panel {
  position: fixed;
  top: 62px;
  right: 20px;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  z-index: 50;
}

.usage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.icon {
  border: 0;
  background: transparent;
  color: #c3c8d4;
  font-size: 20px;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
}

.icon:hover {
  background: #f3f4f7;
  color: var(--text);
}

.usage-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  font-size: 13.5px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.usage-row:last-child {
  border-bottom: 0;
}

/* ------------------------------------------------------------------ 提示 */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: #14161d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  max-width: 80vw;
  box-shadow: var(--shadow);
}

.toast.ok {
  background: #0f9d63;
}

.toast.error {
  background: var(--danger);
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.think {
  margin: 0 0 10px;
  padding: 9px 11px;
  background: #f7f8fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: #5b6273;
}

.think summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  font-size: 12.5px;
  user-select: none;
  list-style: none;
}

.think summary::-webkit-details-marker {
  display: none;
}

.think summary::before {
  content: "▸ ";
}

.think[open] summary::before {
  content: "▾ ";
}

.think-body {
  margin-top: 7px;
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
}

.answer:empty {
  display: none;
}

@media (max-width: 560px) {
  .bar-inner,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .chat {
    padding: 16px 14px 4px;
  }

  .bubble {
    max-width: 88%;
  }

  .stat {
    font-size: 12px;
    padding: 4px 9px;
  }

  .setup form {
    flex-direction: column;
  }
}
