:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e3e5e8;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --chip-bg: #eef1f5;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 12px; }
.error { color: var(--bad); font-size: 13px; }

/* ---- 登录 ---- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 32px;
  width: 340px;
  box-shadow: 0 8px 30px rgba(0,0,0,.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .hint { margin: 0 0 20px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 12px;
}
.login-card button {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  cursor: pointer;
}

/* ---- 顶栏 ---- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0;
  z-index: 5;
}
.brand { font-weight: 600; font-size: 15px; cursor: pointer; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.top-actions { display: flex; align-items: center; gap: 14px; }

/* ---- 两栏布局 ---- */
.layout {
  display: flex;
  gap: 18px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 60px;
  align-items: flex-start;
}
.sidebar {
  flex: none;
  width: 220px;
  position: sticky;
  top: 64px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.side-item:hover { background: #e9ecf1; }
.side-item.active { background: var(--card); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.side-hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.side-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-badges { display: flex; align-items: center; gap: 5px; flex: none; }
.side-badge {
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.side-badge.alt { background: #e8f0fe; color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.bad { background: var(--bad); }

main { flex: 1; min-width: 0; }

@media (max-width: 760px) {
  .layout { flex-direction: column; gap: 12px; padding: 12px 10px 40px; }
  /* 侧栏在小屏变成横向胶囊条 */
  .sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .side-item {
    width: auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    background: var(--card);
  }
  .side-item.active { box-shadow: none; border-color: var(--accent); color: var(--accent); }
  .side-hint { display: none; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; row-gap: 6px; }
  .top-actions { gap: 8px; }
  .card { padding: 14px; border-radius: 10px; margin-bottom: 12px; }
  .repo-title { font-size: 16px; }
  /* 条目允许折行，长标题不挤压操作按钮 */
  .item { flex-wrap: wrap; row-gap: 2px; }
  .item a { white-space: normal; min-width: 0; }
  .item .no { min-width: 0; }
  .agent-current { font-size: 17px; }
  dialog { width: calc(100vw - 40px); max-width: 320px; }
  .toast { bottom: 16px; font-size: 12px; }
}

/* ---- 卡片 ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}
.repo-title { font-size: 18px; margin: 2px 0 14px; }

button {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { opacity: .9; }
button.ghost { border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- agent 区 ---- */
.agent-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.agent-current { font-size: 20px; font-weight: 700; }
.agent-switch { display: flex; gap: 8px; }
.agent-switch select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
}
.agent-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 6px 0 14px;
}
.chip {
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--muted);
}
.chip b { color: var(--ink); font-weight: 600; }
.duty-row { display: flex; align-items: center; gap: 12px; }

/* ---- 需要我处理 ---- */
.at-banner {
  background: #fdeaea;
  color: var(--bad);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.at-banner .at-fix { flex: none; }
/* 设置页：agent 密钥行 */
#agent-keys .item { flex-wrap: wrap; row-gap: 4px; }
#agent-keys .item .no { font-weight: 600; color: var(--ink); min-width: 88px; }
#agent-keys .key-desc { color: var(--muted); font-size: 12px; flex: 1; min-width: 200px; }
#agent-keys .item .meta { flex-wrap: wrap; row-gap: 4px; }
#agent-keys code {
  background: var(--chip-bg);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12px;
}
.card .hint a { color: var(--accent); text-decoration: none; }
.card .hint a:hover { text-decoration: underline; }
.card p.hint { margin: 0 0 10px; }
/* 提需求表单 */
#req-form input, #req-form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 8px;
  font-family: inherit;
  resize: vertical;
}
.at-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin: 12px 0 2px;
}
.at-group-title:first-child { margin-top: 0; }
.empty.clean { color: var(--ok); padding: 8px 0; font-size: 14px; }

/* ---- 条目 ---- */
.item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 0;
  border-top: 1px dashed var(--line);
}
.at-group-title + .item { border-top: 0; }
.item .no { color: var(--muted); min-width: 52px; flex: none; }
.item a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item a:hover { color: var(--accent); }
.item .meta { margin-left: auto; flex: none; display: flex; align-items: center; gap: 6px; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 11px;
}
.pill.ok    { background: #e7f6ec; color: var(--ok); }
.pill.run   { background: #e8f0fe; color: var(--accent); }
.pill.warn  { background: #fdf3e3; color: var(--warn); }
.pill.bad   { background: #fdeaea; color: var(--bad); }
.empty { color: var(--muted); padding: 6px 0; }

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%; bottom: 32px;
  transform: translateX(-50%);
  background: #1f2328;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  max-width: 80vw;
  z-index: 50;
}
.toast.bad { background: var(--bad); }

/* ---- 修改密码弹窗 ---- */
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  width: 320px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 14px; font-size: 16px; }
dialog input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 10px;
}
.pw-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
