:root {
  --bg: #eef2fb;
  --surface: #ffffff;
  --surface-2: #f6f8fe;
  --text: #16203a;
  --muted: #64708c;
  --line: #e2e8f5;
  --primary: #2456e6;
  --primary-dark: #1a43bd;
  --accent: #12b886;
  --warn: #f59f0b;
  --danger: #e03b3b;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(25, 45, 100, 0.08);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: radial-gradient(1200px 500px at 50% -200px, #dbe6ff 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; line-height: 1.35; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p { margin: 0; line-height: 1.7; }
a { color: var(--primary); }

/* ------------------------------- 顶栏 ------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 26px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: 0.5px; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.identity { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.name-input {
  width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}

.name-input:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(36, 86, 230, 0.35);
  outline-offset: 1px;
  border-color: var(--primary);
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-ok { background: #e6f8f0; color: #0b7a56; border-color: #b6ebd5; }
.badge-warn { background: #fff5e2; color: #9a6300; border-color: #ffe0ab; }
.badge-error { background: #fdeaea; color: #a32020; border-color: #f7c6c6; }

.tabs {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 10px 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--primary); color: #fff; font-weight: 600; }

/* ------------------------------- 布局 ------------------------------- */
.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  flex: 1;
}

.page { display: none; }
.page.is-active { display: block; animation: fade 0.2s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #2456e6 0%, #4a7dff 55%, #12b886 160%);
  color: #fff;
  border: none;
}
.hero h1 { font-size: 28px; margin: 4px 0 6px; }
.hero .eyebrow { font-size: 13px; opacity: 0.85; letter-spacing: 1px; }
.hero-sub { opacity: 0.92; font-size: 14px; }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 82px;
  text-align: center;
}
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; opacity: 0.9; }

.announcement { border-left: 4px solid var(--warn); }
.announcement h2 { margin-bottom: 8px; }
.announcement p { white-space: pre-wrap; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.quick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  margin-bottom: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.quick:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(25, 45, 100, 0.14); }
.quick-icon { font-size: 24px; }
.quick small { color: var(--muted); font-size: 12px; line-height: 1.5; }

.steps { margin: 10px 0 0; padding-left: 20px; color: var(--muted); line-height: 2; }

/* ------------------------------- 表单 ------------------------------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input[type="text"], input[type="password"], input[type="file"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

textarea { resize: vertical; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input[type="text"] { flex: 1 1 220px; width: auto; }
.row > select { flex: 0 0 auto; width: auto; }
.row.right { justify-content: flex-end; }

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--danger); border-color: #f7c6c6; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.hint.tiny { font-size: 12px; margin: 8px 0 0; }

/* ------------------------------- 聊天 ------------------------------- */
.chat-card { display: flex; flex-direction: column; }
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 6px 4px 12px;
}

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .avatar { font-size: 20px; flex-shrink: 0; width: 30px; text-align: center; }
.bubble {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  max-width: min(720px, 88%);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  font-size: 14.5px;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble { background: #e7eeff; border-color: #cfdcff; }
.meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg.user .meta { text-align: right; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
}
.chip:hover { color: var(--primary); border-color: #cfdcff; background: #eef3ff; }

.chat-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 8px; }
.chat-form textarea { flex: 1; }

.typing span {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ------------------------------- 信息流 ------------------------------- */
.feed { display: flex; flex-direction: column; gap: 12px; }

.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.item-head strong { font-size: 14px; }
.item-head .time { color: var(--muted); font-size: 12px; margin-left: auto; }
.item-body { white-space: pre-wrap; word-break: break-word; line-height: 1.75; font-size: 14.5px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mini {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.mini:hover { color: var(--primary); border-color: #cfdcff; }
.mini.danger:hover { color: var(--danger); border-color: #f7c6c6; }

.tag { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: #eef3ff; color: var(--primary); border: 1px solid #d8e2ff; }
.tag.open { background: #fff5e2; color: #9a6300; border-color: #ffe0ab; }
.tag.resolved { background: #e6f8f0; color: #0b7a56; border-color: #b6ebd5; }

.answers { margin-top: 12px; padding-left: 12px; border-left: 3px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.answer { font-size: 14px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.answer .who { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.answer.is-ai { background: #f4f8ff; border-radius: 10px; padding: 10px 12px; }

.answer-form { display: flex; gap: 8px; margin-top: 10px; }
.answer-form input { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; font-size: 14px; }
.file-size { color: var(--muted); font-size: 12px; }

.env-box { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; }
.env-box h3 { font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
.env-box pre {
  background: #0f1830;
  color: #b9c8ff;
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ------------------------------- 其它 ------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: rgba(16, 26, 51, 0.94);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 60;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(170, 32, 32, 0.95); }

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  width: 100%;
}

/* ------------------------------- 移动端 ------------------------------- */
@media (max-width: 720px) {
  h1, .hero h1 { font-size: 22px; }
  .container { padding: 14px 12px 32px; }
  .card { padding: 14px; border-radius: 14px; }
  .brand-text small { display: none; }
  .name-input { width: 104px; }
  .chat-log { max-height: 46vh; }
  .chat-form { flex-direction: column; align-items: stretch; }
  .chat-form .btn { width: 100%; }
  .bubble { max-width: 92%; }
  .row.right { justify-content: stretch; }
  .row.right .btn { flex: 1; }
  .footer { flex-direction: column; }
}
