:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --surface-2: #f0f0f1;
  --line: rgba(0,0,0,.06);
  --line-strong: rgba(0,0,0,.12);
  --text: #171717;
  --text-2: #2f3b4c;
  --muted: #3a4658;
  --primary: #171717;
  --on-primary: #fff;
  --soft: #f0f0f1;
  --ok: #047857; --ok-bg: #ecfdf5;
  --warn: #b45309; --warn-bg: #fffbeb;
  --info: #334155; --info-bg: #f4f4f5;
  --side: #f7f7f8;
  --side-active: #ececed;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.06);
  --radius: 20px;
  --radius-sm: 14px;
  --font: ui-sans-serif, system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.demo-banner {
  position: sticky; top: 0; z-index: 50;
  background: #171717; color: #fafafa;
  padding: 10px 18px; font-size: 13px; line-height: 1.5;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.demo-banner b { font-weight: 600; }
.demo-banner .tag {
  display: inline-flex; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.12); font-size: 12px; margin-right: 6px;
}

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 42px);
}
.sidebar {
  position: sticky; top: 42px; height: calc(100vh - 42px);
  padding: 22px 14px 18px;
  background: var(--side);
  border-right: 1px solid var(--line);
  overflow: auto;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 18px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: #171717; color: #fff; display: grid; place-items: center; font-weight: 700;
}
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; margin: 0 4px 12px;
}
.mode-switch button {
  border: 0; background: transparent; border-radius: 999px;
  padding: 8px 10px; font-size: 13px; color: var(--muted);
}
.mode-switch button.active { background: var(--side-active); color: var(--text); font-weight: 600; }

.account-box {
  margin: 0 4px 16px; padding: 12px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.account-box select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; background: #fff; margin-top: 8px;
}
.account-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

.menu { display: flex; flex-direction: column; gap: 2px; }
.menu-title { font-size: 12px; color: var(--muted); padding: 10px 10px 4px; }
.menu-item {
  appearance: none; border: 0; background: transparent; text-align: left;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; color: var(--text-2); width: 100%;
}
.menu-item:hover { background: var(--soft); }
.menu-item.active {
  background: var(--side-active); color: var(--text); font-weight: 600;
  box-shadow: inset 3px 0 0 #171717;
}
.menu-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-sub { padding-left: 12px; }
.menu-tag {
  margin-left: auto; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--info-bg); color: var(--info);
}

.main { padding: 28px 40px 72px; max-width: 1080px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--text-2); line-height: 1.6; font-size: 15px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 56px; }
}

.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.stat .h { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
  appearance: none; border: 1px solid var(--line-strong); background: #fff;
  border-radius: 10px; min-height: 38px; padding: 0 14px; font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; color: var(--text);
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: #000; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 3px 8px; border-radius: 999px; font-weight: 550;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.info { background: var(--info-bg); color: var(--info); }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 12px;
  background: #fff; display: grid; gap: 8px;
}
.list-item:hover { border-color: var(--line-strong); }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 13px; color: var(--muted); line-height: 1.5; }
.seg {
  display: inline-flex; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; box-shadow: var(--shadow);
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 12px; border-radius: 999px; font-size: 13px;
}
.seg button.active { background: var(--side-active); color: var(--text); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 550; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 12px; background: #fff; width: 100%;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

.hero {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.hero-kicker {
  display: inline-flex; font-size: 12px; font-weight: 600; color: var(--text);
  background: var(--soft); border: 1px solid var(--line); padding: 5px 10px;
  border-radius: 999px; margin-bottom: 12px;
}
.hero h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--text-2); line-height: 1.65; }
.path { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.path .step {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.path .step:hover { border-color: var(--line-strong); }
.path .arrow { color: var(--muted); }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 240px minmax(0,1fr); gap: 14px; min-height: 620px; }
.chat-side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px; box-shadow: var(--shadow);
}
.chat-side .new {
  width: 100%; margin-bottom: 10px;
}
.thread {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 10px; border-radius: 10px; color: var(--text-2); margin-bottom: 2px;
}
.thread.active, .thread:hover { background: var(--soft); color: var(--text); }
.chat-main {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 620px;
}
.chat-welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center;
}
.chat-welcome h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.03em; }
.chat-welcome p { margin: 0 0 22px; color: var(--muted); max-width: 42ch; line-height: 1.6; }
.chat-msgs { flex: 1; overflow: auto; padding: 22px 22px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 78%; line-height: 1.65; white-space: pre-wrap; }
.msg.user {
  align-self: flex-end; background: var(--soft); border-radius: 16px; padding: 12px 14px;
}
.msg.assistant { align-self: flex-start; }
.msg .tool {
  margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: #fafafa; font-size: 14px;
}
.chat-input {
  margin: 8px 16px 16px; border: 1px solid var(--line-strong); border-radius: 18px;
  padding: 12px; background: #fff; box-shadow: var(--shadow);
}
.chat-input textarea {
  width: 100%; border: 0; outline: none; resize: none; min-height: 56px; line-height: 1.5;
}
.chat-input .actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.28); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 80; padding: 20px;
}
.modal {
  width: min(640px, 100%); background: #fff; border-radius: 18px;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 18px;
}
.modal h3 { margin: 0 0 12px; }
.modal .footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  background: #171717; color: #fff; padding: 12px 14px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow-lg); max-width: 360px;
}

.empty { color: var(--muted); padding: 28px 8px; text-align: center; }
.pre {
  white-space: pre-wrap; background: #fafafa; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.65;
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 550; font-size: 12px; }
.notice {
  border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.55; margin-bottom: 12px;
}
.notice.info { background: var(--info-bg); color: var(--info); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

@media (max-width: 860px) {
  .chat-layout { grid-template-columns: 1fr; }
}
