:root {
  --bg: #181a20;
  --bg-side: #15171c;
  --panel: #1e2329;
  --line: #24282f;
  --line-strong: #353a42;
  --card: #262a32;
  --card-hover: #2e333c;
  --text: #eaecef;
  --text-2: #c3c8cf;
  --text-3: #848e9c;
  --text-4: #5e6673;
  --yellow: #fcd535;
  --yellow-hover: #f0c929;
  --brand: #f0b90b;
  --green: #2ebd85;
  --red: #f6465d;
  --blue: #5b8dff;
  --purple: #9b7bff;
  --cyan: #22c3d6;
  --side-w: 300px;
  color-scheme: dark;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #2f343c transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2f343c; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
h1, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon.logo { stroke: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  color: var(--text);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .06); }

.app { display: flex; height: 100%; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--side-w); flex: none;
  display: flex; flex-direction: column;
  padding: 28px 12px 18px;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: width .25s ease;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding-left: 6px; }
.ai-brand { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ai-brand-mark { width: 28px; height: 28px; }
.ai-brand-text {
  font-size: 17px; font-weight: 500;
  background: linear-gradient(90deg, #6aa8ff, #a48bff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pro-tag { padding: 0 5px; border: 1px solid #7d8bff; border-radius: 4px; font-size: 12px; line-height: 17px; color: #8ea0ff; }
.chain-tag { padding: 0 5px; border-radius: 4px; background: rgba(240, 185, 11, .14); font-size: 11px; font-weight: 600; line-height: 18px; color: var(--brand); }
.collapse-btn .icon { transition: transform .25s; }

.side-menu { display: flex; flex-direction: column; gap: 4px; margin-top: 36px; }
.side-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 42px; padding: 0 10px; border-radius: 10px;
  font-size: 15px; font-weight: 500; text-align: left; white-space: nowrap;
  transition: background .15s;
}
.side-item:hover { background: rgba(255, 255, 255, .05); }
.side-item .badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

.history { display: none; flex: 1; min-height: 0; margin-top: 20px; overflow-y: auto; }
.history.has-items { display: block; }
.history-title { padding: 0 10px 8px; font-size: 12px; color: var(--text-4); }
.run-count { display: inline-flex; align-items: center; color: var(--green); }
.run-count .stage-dot { width: 6px; height: 6px; margin: 0 4px 0 2px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 6px 0 10px; border-radius: 8px;
  font-size: 14px; color: var(--text-2); cursor: pointer;
}
.history-item:hover, .history-item.active { background: rgba(255, 255, 255, .06); color: var(--text); }
.history-item > .icon { color: var(--text-4); }
.history-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .del { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--text-3); opacity: 0; }
.history-item:hover .del { opacity: 1; }
.history-item .del:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.stage-dot { flex: none; width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; background: var(--text-4); }
.stage-dot.green { background: var(--green); box-shadow: 0 0 0 0 rgba(46, 189, 133, .6); animation: live 1.8s infinite; }
.stage-dot.blue { background: var(--blue); }
.stage-dot.amber { background: var(--brand); }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(46, 189, 133, .55); } 70% { box-shadow: 0 0 0 6px rgba(46, 189, 133, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 189, 133, 0); } }

.side-user { position: relative; margin-top: auto; padding-top: 12px; }
.connect-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 42px; border-radius: 10px;
  border: 1px solid rgba(240, 185, 11, .5);
  background: rgba(240, 185, 11, .08); color: var(--brand);
  font-weight: 600; white-space: nowrap;
  transition: background .15s;
}
.connect-btn:hover { background: rgba(240, 185, 11, .16); }
.account-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px; border-radius: 10px; text-align: left;
  transition: background .15s;
}
.account-btn:hover { background: rgba(255, 255, 255, .05); }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15); }
.avatar.sm { width: 26px; height: 26px; }
.acct-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acct-text b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-text small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-count { padding: 0 6px; border-radius: 9px; background: rgba(255, 255, 255, .08); font-size: 11px; color: var(--text-2); }
.account-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30;
  padding: 6px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  animation: pop .14s ease-out;
}
.am-title { padding: 6px 8px; font-size: 12px; color: var(--text-4); }
.am-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px; border-radius: 8px; text-align: left; font-size: 14px;
}
.am-item:hover { background: rgba(255, 255, 255, .06); }
.am-item.active { background: rgba(240, 185, 11, .08); }
.am-item.active > .icon { color: var(--brand); }
.am-item.danger { color: var(--red); }
.am-sep { display: block; height: 1px; margin: 6px 4px; background: var(--line); }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

.scrim { display: none; }

@media (min-width: 769px) {
  body.sidebar-collapsed .sidebar { width: 68px; }
  body.sidebar-collapsed .ai-brand,
  body.sidebar-collapsed .side-item span,
  body.sidebar-collapsed .side-item .badge,
  body.sidebar-collapsed .history,
  body.sidebar-collapsed .acct-text,
  body.sidebar-collapsed .acct-count,
  body.sidebar-collapsed .account-btn > .icon,
  body.sidebar-collapsed .connect-btn span { display: none; }
  body.sidebar-collapsed .sidebar-head { justify-content: center; padding-left: 0; }
  body.sidebar-collapsed .collapse-btn .icon { transform: scaleX(-1); }
  body.sidebar-collapsed .side-item { justify-content: center; padding: 0; }
  body.sidebar-collapsed .account-btn { justify-content: center; padding: 6px 0; }
  body.sidebar-collapsed .account-menu { width: 280px; right: auto; }
}

/* ---------- 主区域 ---------- */
.main {
  position: relative; flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 255, 255, .04), transparent 70%),
    radial-gradient(700px 600px at 100% 100%, rgba(0, 0, 0, .25), transparent 70%),
    linear-gradient(180deg, #1a1d24, #1d2028);
}
.mobile-bar { display: none; }

/* ---------- 首页 ---------- */
.home { flex: 1; min-height: 0; display: none; flex-direction: column; overflow-y: auto; }
.view-home .home { display: flex; }
.home-inner { width: 100%; max-width: 880px; margin: auto; padding: 40px 24px 12px; }
.hero { display: flex; flex-direction: column; align-items: center; padding-bottom: 48px; text-align: center; }
.hero-title { display: flex; align-items: center; gap: 14px; font-size: 44px; font-weight: 700; line-height: 1.2; letter-spacing: 1px; }
.hero-mark { width: 54px; height: 54px; }
.hero-sub { margin-top: 10px; font-size: 22px; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: rgba(0, 0, 0, .18);
  color: var(--text-2); font-size: 15px; font-weight: 500;
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--text); border-color: #474d57; background: rgba(255, 255, 255, .04); }
.chip.icon-only { width: 38px; padding: 0; justify-content: center; }

.disclaimer { flex: none; padding: 12px 24px 16px; text-align: center; font-size: 12px; color: var(--text-4); }

/* ---------- 输入框 ---------- */
.composer {
  position: relative;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: rgba(0, 0, 0, .12);
  transition: border-color .15s;
}
.composer:focus-within { border-color: #4a505a; }
.composer textarea {
  display: block; width: 100%; min-height: 56px; max-height: 200px;
  padding: 14px 16px 6px; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--text);
  font: inherit; font-size: 15px; line-height: 1.6;
}
.composer textarea::placeholder { color: #6b7380; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px 12px; }
.bar-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 8px; border-radius: 6px;
  background: rgba(255, 255, 255, .04);
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.bar-chip.muted { color: var(--text-3); }
.model-picker { position: relative; flex: none; }
.bar-chip.ai-chip { height: 30px; gap: 7px; color: var(--text-2); background: #2b313c; }
.bar-chip.ai-chip:hover:not(:disabled), .bar-chip.ai-chip[aria-expanded="true"] { color: var(--text); background: #343b47; }
.bar-chip.ai-chip:disabled { opacity: .6; }
.claude-icon { width: 18px; height: 18px; }
.model-chevron { color: var(--text-3); transition: transform .15s; }
.ai-chip[aria-expanded="true"] .model-chevron { transform: rotate(180deg); }
.model-menu {
  position: absolute; bottom: calc(100% + 10px); left: 0; z-index: 60;
  width: 344px; padding: 8px; border: 1px solid #343b45; border-radius: 16px;
  background: #222831; box-shadow: 0 16px 42px #0006;
}
.model-option { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border-radius: 10px; text-align: left; }
.model-option:hover, .model-option:focus-visible { background: #2c333e; }
.model-option:focus-visible, .ai-chip:focus-visible { outline: 2px solid #d97757; outline-offset: 2px; }
.model-option > .claude-icon { width: 26px; height: 26px; }
.model-option-copy { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.model-option-copy b { color: var(--text); font-size: 17px; font-weight: 600; }
.model-option-copy > span { color: #969eaa; font-size: 13px; }
.model-option-copy small { color: #aeb5bf; font-size: 11px; margin-top: 3px; }
.model-check { width: 22px; height: 22px; opacity: 0; stroke-width: 2.8; }
.model-option[aria-checked="true"] .model-check { opacity: 1; }
.bar-divider { width: 1px; height: 16px; background: var(--line-strong); }
.send-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; margin-left: auto; border-radius: 9px;
  background: rgba(255, 255, 255, .04); color: var(--text-4);
  transition: background .15s, color .15s;
}
.send-btn:not(:disabled) { background: var(--yellow); color: #181a20; }
.send-btn:not(:disabled):hover { background: var(--yellow-hover); }
.composer.busy .send-btn { background: rgba(255, 255, 255, .04); color: var(--text-4); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; top: 22px; left: 50%; z-index: 200;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: 10px;
  background: #2b3139; color: var(--text); font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #3a2329; color: #ffb3bf; }
.toast.success { background: #1e3a2f; color: #8ff0c4; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  :root { --side-w: 260px; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  body.sidebar-open .sidebar { transform: none; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0, 0, 0, .5);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .mobile-bar { display: flex; flex: none; padding: 10px 8px 0; }
  .home-inner { padding: 16px 16px 8px; }
  .hero { padding-bottom: 32px; }
  .hero-title { font-size: 32px; }
  .hero-mark { width: 40px; height: 40px; }
  .hero-sub { font-size: 18px; }
}
