/* WorkBuddy Web - 深色 DSH 风格，移动优先，零依赖 */
:root {
  --bg: #0a0c11;
  --bg-soft: #0f131a;
  --card: #141a23;
  --card-2: #1a212c;
  --border: #232b38;
  --border-soft: #1b222d;
  --text: #e9edf4;
  --text-dim: #aab4c4;
  --muted: #717d90;
  --accent: #5b8cff;
  --accent-2: #8fb0ff;
  --accent-ink: #ffffff;
  --green: #3ddc97;
  --red: #ff6b6b;
  --amber: #ffb454;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 14px;
  --sidebar-w: 282px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-2: #eef1f6;
  --border: #dde3ec;
  --border-soft: #e6ebf2;
  --text: #18202c;
  --text-dim: #47536a;
  --muted: #7b8698;
  --accent: #3568ee;
  --accent-2: #2a56c9;
  --accent-ink: #ffffff;
  --shadow: 0 10px 30px rgba(24, 32, 44, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.62 -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- 布局 ---------- */
.app {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(86vw, 320px);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform .22s ease;
  z-index: 46;
  padding-top: var(--safe-top);
}

.sidebar.open { transform: none; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(91, 140, 255, .10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(143, 176, 255, .06), transparent 55%),
    var(--bg);
}

@media (min-width: 900px) {
  .sidebar {
    position: static;
    transform: none;
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    padding-top: 0;
  }
}

/* ---------- 侧栏 ---------- */
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #8a6bff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .5px;
  box-shadow: 0 4px 14px rgba(91, 140, 255, .35);
  flex: 0 0 auto;
}

.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list-label {
  padding: 12px 16px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  -webkit-overflow-scrolling: touch;
}

.session-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  color: var(--text-dim);
}
.session-item:hover { background: var(--card); color: var(--text); }
.session-item.active {
  background: linear-gradient(180deg, rgba(91, 140, 255, .16), rgba(91, 140, 255, .07));
  border-color: rgba(91, 140, 255, .35);
  color: var(--text);
}
.session-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.session-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(145deg, #2b3648, #1a212c);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  flex: 0 0 auto;
}
.user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 5;
  flex: 0 0 auto;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--card); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--card);
  white-space: nowrap;
  flex: 0 0 auto;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(61, 220, 151, .4);
  flex: 0 0 auto;
}
.status.ok .status-dot { background: var(--green); animation: pulse 2.4s infinite; }
.status.bad .status-dot { background: var(--red); }
.status.wait .status-dot { background: var(--amber); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, .45); }
  70% { box-shadow: 0 0 0 7px rgba(61, 220, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}

.selects { display: flex; align-items: center; gap: 6px; min-width: 0; }
.select-wrap { position: relative; min-width: 0; }
select.mini {
  appearance: none;
  -webkit-appearance: none;
  max-width: 128px;
  height: 32px;
  padding: 0 26px 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 12.5px;
  text-overflow: ellipsis;
  outline: none;
}
select.mini:focus { border-color: var(--accent); }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 10px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
@media (max-width: 560px) {
  .status .status-text { display: none; }
  .topbar .selects .mode-select { display: none; }
  select.mini { max-width: 88px; }
}

/* ---------- 聊天区 ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 12px 6px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.messages {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 8px;
}

.msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: stretch; }

.role {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.role .badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.bubble-user {
  max-width: min(86%, 660px);
  background: linear-gradient(160deg, rgba(91, 140, 255, .22), rgba(91, 140, 255, .12));
  border: 1px solid rgba(91, 140, 255, .32);
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
}

.bubble-assistant {
  background: color-mix(in srgb, var(--card) 72%, transparent);
  border: 1px solid var(--border-soft);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 14px;
  min-width: 0;
}

/* 推理折叠块 */
.thought {
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .015);
  margin-bottom: 8px;
  overflow: hidden;
}
.thought summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
.thought summary::-webkit-details-marker { display: none; }
.thought summary .chev {
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  margin-right: 2px;
}
.thought[open] summary .chev { transform: rotate(45deg); }
.thought-body {
  padding: 0 12px 10px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* 工具卡片 */
.tool-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  margin: 8px 0;
  overflow: hidden;
  font-size: 13px;
}
.tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
}
.tool-ico {
  width: 22px; height: 22px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--card-2);
  color: var(--text-dim);
  font-size: 12px;
  flex: 0 0 auto;
}
.tool-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.tool-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}
.tool-status.running { color: var(--amber); border-color: rgba(255, 180, 84, .4); }
.tool-status.done { color: var(--green); border-color: rgba(61, 220, 151, .35); }
.tool-status.error { color: var(--red); border-color: rgba(255, 107, 107, .4); }
.tool-body { border-top: 1px solid var(--border); padding: 10px 12px; display: none; }
.tool-card.open .tool-body { display: block; }
.tool-body pre {
  margin: 6px 0 0;
  padding: 10px;
  background: var(--bg-soft);
  border-radius: 9px;
  overflow: auto;
  max-height: 260px;
  font-size: 12px;
}
.tool-body .lbl { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.tool-out { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; color: var(--text-dim); margin-top: 6px; }

/* markdown 正文 */
.md { font-size: 14.5px; line-height: 1.72; word-break: break-word; overflow-wrap: anywhere; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 .8em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 1.2em 0 .55em;
  line-height: 1.32;
  font-weight: 700;
}
.md h1 { font-size: 1.32em; }
.md h2 { font-size: 1.2em; }
.md h3 { font-size: 1.08em; }
.md h4, .md h5, .md h6 { font-size: 1em; color: var(--text-dim); }
.md ul, .md ol { margin: 0 0 .8em; padding-left: 1.45em; }
.md li { margin: .18em 0; }
.md li > ul, .md li > ol { margin: .2em 0 .2em; }
.md blockquote {
  margin: 0 0 .8em;
  padding: .2em 0 .2em .95em;
  border-left: 3px solid rgba(91, 140, 255, .5);
  color: var(--text-dim);
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.1em 0; }
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  background: rgba(127, 145, 175, .16);
  border: 1px solid rgba(127, 145, 175, .18);
  padding: .08em .38em;
  border-radius: 6px;
  word-break: break-word;
}
.md .table-wrap { overflow-x: auto; margin: 0 0 .9em; border: 1px solid var(--border); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md th, .md td { padding: 7px 11px; border-bottom: 1px solid var(--border-soft); text-align: left; }
.md th { background: var(--card-2); font-weight: 650; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }

.code-block {
  position: relative;
  margin: 0 0 1em;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  background: #0b0f16;
}
html[data-theme="light"] .code-block { background: #f6f8fb; }
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, .03);
  border-bottom: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--muted);
}
html[data-theme="light"] .code-head { background: rgba(0, 0, 0, .025); }
.code-lang { font-family: ui-monospace, Menlo, monospace; letter-spacing: .03em; }
.copy-btn {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 7px;
  background: transparent;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12.8px;
  line-height: 1.6;
}
.code-block code {
  background: none;
  border: 0;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: inherit;
  white-space: pre;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -.16em;
  background: var(--accent);
  border-radius: 2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.msg-actions { display: flex; gap: 6px; margin-top: 2px; opacity: .55; }
.msg-actions:hover { opacity: 1; }
.chip-btn {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 9px;
}
.chip-btn:hover { color: var(--text); border-color: var(--accent); }

/* 空状态 */
.empty {
  max-width: 620px;
  margin: 6vh auto 0;
  text-align: center;
  padding: 0 8px;
}
.empty-logo {
  width: 62px; height: 62px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--accent), #8a6bff);
  display: grid; place-items: center;
  font-weight: 800; font-size: 24px; color: #fff;
  box-shadow: 0 14px 40px rgba(91, 140, 255, .35);
}
.empty h1 { font-size: 20px; margin: 0 0 8px; }
.empty p { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggest {
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
}
.suggest:hover { border-color: var(--accent); color: var(--text); }

/* ---------- 输入区 ---------- */
.composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.composer-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--card);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer-inner:focus-within { border-color: rgba(91, 140, 255, .55); box-shadow: 0 0 0 3px rgba(91, 140, 255, .12); }
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 26px;
  max-height: 168px;
  padding: 5px 0;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
.composer textarea::placeholder { color: var(--muted); }
.send-btn, .stop-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.send-btn { background: var(--accent); color: var(--accent-ink); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }
.send-btn svg, .stop-btn svg { width: 17px; height: 17px; }
.stop-btn { background: rgba(255, 107, 107, .16); color: var(--red); border: 1px solid rgba(255, 107, 107, .35); }
.composer-hint {
  max-width: 860px;
  margin: 6px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}
.composer-hint .kbd {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
  font-size: 10.5px;
}
.usage { font-variant-numeric: tabular-nums; }

/* ---------- 抽屉/遮罩 ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .52);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 44;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform .22s ease;
  z-index: 48;
  padding-top: var(--safe-top);
}
.panel.open { transform: none; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 0;
}
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--card); border-color: var(--border); }
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}
.panel-foot {
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11.5px;
  color: var(--muted);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  word-break: break-all;
}
.crumb { color: var(--text-dim); padding: 2px 5px; border-radius: 6px; }
.crumb:hover { background: var(--card); color: var(--text); }
.crumb-sep { opacity: .55; }

.file-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: left;
  color: var(--text-dim);
  border: 1px solid transparent;
}
.file-item:hover { background: var(--card); color: var(--text); }
.file-ico {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 12px;
  background: var(--card-2);
  color: var(--muted);
  flex: 0 0 auto;
}
.file-ico.dir { color: var(--accent-2); }
.file-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.file-size { font-size: 11px; color: var(--muted); flex: 0 0 auto; }

.preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.preview-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview {
  margin: 0;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 11px;
  font: 12.2px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 62vh;
  overflow: auto;
}

.skill-sec { margin-bottom: 18px; }
.skill-sec h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.skill-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--card);
  margin-bottom: 6px;
  display: flex;
  gap: 9px;
  align-items: baseline;
}
.skill-item:hover { border-color: var(--accent); }
.skill-cmd {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  color: var(--accent-2);
  white-space: nowrap;
  flex: 0 0 auto;
}
.skill-desc { font-size: 12px; color: var(--muted); margin: 0; flex: 1; min-width: 0; }
.plugin-card {
  border: 1px solid var(--border-soft);
  background: var(--card);
  border-radius: 11px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.plugin-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.plugin-name { font-size: 13px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plugin-ver { font-size: 10.5px; color: var(--muted); }
.plugin-desc { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.55; }
.pill {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.pill.on { color: var(--green); border-color: rgba(61, 220, 151, .35); }
.pill.off { color: var(--muted); opacity: .8; }

/* ---------- 弹窗/提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255, 107, 107, .5); }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  width: min(480px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.modal h2 { margin: 0 0 4px; font-size: 16px; }
.modal .muted { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.perm-cmd {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: 12.5px/1.6 ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  margin-bottom: 14px;
}
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.btn {
  padding: 10px 14px;
  border-radius: 11px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-align: center;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, .4); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 登录页 */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(800px 420px at 50% 0%, rgba(91, 140, 255, .16), transparent 65%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 58px; height: 58px;
  border-radius: 17px;
  margin: 0 auto 16px;
  background: linear-gradient(145deg, var(--accent), #8a6bff);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 21px;
  box-shadow: 0 14px 36px rgba(91, 140, 255, .38);
}
.login-card h1 { text-align: center; font-size: 21px; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  outline: none;
  font-size: 15px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, .13); }
.remember { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 4px 0 18px; user-select: none; }
.remember input { width: 16px; height: 16px; accent-color: var(--accent); }
.login-btn {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #7a63f5);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.login-btn:disabled { opacity: .6; cursor: wait; }
.login-error {
  min-height: 20px;
  font-size: 12.5px;
  color: var(--red);
  margin: 10px 2px 0;
  text-align: center;
}
.login-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 18px; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(127, 145, 175, .22); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(127, 145, 175, .38); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* 细节补充 */
.only-mobile { display: none; }
@media (max-width: 899px) {
  .only-mobile { display: grid; }
}
.thinking-dots { color: var(--muted); opacity: .8; }
.err-note { color: var(--red); font-size: 13.5px; margin: 0; }
.bubble-user { overflow-wrap: anywhere; }
.crumb { border: 0; background: transparent; cursor: pointer; }
