:root {
  --font-sans: "Noto Sans SC", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Fraunces", "Noto Serif SC", Georgia, serif;
  --bg-main: #f7f8f8;
  --bg-white: #fff;
  --sidebar-bg: #f3f4f6;
  --bg-hover: #ececee;
  --brand-primary: #FF6B00;
  --brand-primary-hover: #E85D00;
  --brand-primary-pressed: #CC5200;
  --brand-primary-faint: color-mix(in srgb, #FF6B00 10%, transparent);
  --accent: var(--brand-primary);
  --accent-ink: #fff;
  --bg-selected: color-mix(in srgb, #FF6B00 10%, transparent);
  --ink: #1d1d1f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --err: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 4px 16px rgba(15, 23, 42, .08), 0 16px 48px rgba(15, 23, 42, .06);
  --shell-nav-default: #64748B;
  --shell-nav-hover-text: #CC5200;
  --shell-nav-hover-bg: #FFF3EB;
  --shell-nav-active-text: #FF6B00;
  --shell-nav-active-bg: color-mix(in srgb, #FF6B00 15%, var(--sidebar-bg));
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.55 var(--font-sans);
  color: var(--ink);
  background: var(--bg-main);
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
body.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
}
.brand { color: var(--ink); text-decoration: none; font-weight: 700; }
.top nav { display: flex; gap: 14px; align-items: center; }
.who { color: var(--muted); font-size: 13px; }
main { max-width: 560px; margin: 48px auto; padding: 0 20px; }

.shell-nav {
  display: flex;
  flex-shrink: 0;
  height: 100%;
  background: var(--sidebar-bg);
}
.icon-rail {
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 10px;
  gap: 4px;
}
.ico-group { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; }
.ico-foot { margin-top: auto; }
button.ico {
  padding: 0; border-radius: var(--radius);
  background: transparent; color: var(--shell-nav-default);
}
.ico {
  width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--shell-nav-default);
  text-decoration: none; cursor: pointer; flex-shrink: 0;
  transition: background .15s ease, color .15s ease;
}
.ico svg { width: 18px; height: 18px; display: block; }
.ico:hover { background: var(--shell-nav-hover-bg); color: var(--shell-nav-hover-text); }
.ico.on { background: var(--shell-nav-active-bg); color: var(--shell-nav-active-text); }
.ico.brand {
  font-family: var(--font-display); font-weight: 640; font-size: 17px;
  color: var(--shell-nav-active-text); background: var(--shell-nav-active-bg);
}

.side-panel {
  width: 290px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 12px 12px;
  overflow: hidden;
  transition: width .22s cubic-bezier(.4, 0, .2, 1), padding .22s cubic-bezier(.4, 0, .2, 1);
}
.shell-nav.collapsed .side-panel,
body.no-side .side-panel { width: 0; padding-left: 0; padding-right: 0; }
.side-panel .panel { min-width: 266px; }
.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel[hidden] { display: none; }
#panel-files.drop-on {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 12px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 6px 12px;
}
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.panel-head .wait-spin { width: 12px; height: 12px; }
.panel-sub { font-size: 12px; color: var(--muted); }
.panel-new {
  font-size: 12px; font-weight: 600; color: var(--brand-primary);
  text-decoration: none; padding: 4px 8px; border-radius: 6px;
  border: none; background: none; cursor: pointer; font-family: inherit;
}
.panel-new:hover { background: var(--shell-nav-hover-bg); color: var(--brand-primary-hover); }
.panel-new:disabled { opacity: .35; cursor: default; }
.panel-ops { display: flex; gap: 2px; }
.tree-line { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tree-check {
  display: none; flex: none; width: 14px; height: 14px; margin: 0 2px 0 4px; padding: 0;
  accent-color: var(--accent); border: 0; appearance: auto;
}
.panel.selecting .tree-check { display: inline-block; }
.tree-line .tree-row { flex: 1; min-width: 0; }
.tree-node.on > .tree-line { background: var(--bg-selected); border-radius: 6px; }
.tree-menu {
  position: fixed; z-index: 40; min-width: 112px; padding: 6px;
  background: var(--bg-white); border-radius: 10px; box-shadow: var(--shadow);
  display: grid;
}
.tree-menu button {
  background: transparent; color: var(--ink); border: 0; border-radius: 6px;
  padding: 7px 10px; text-align: left; font: inherit; font-size: 13px;
}
.tree-menu button:hover { background: var(--bg-hover); }
.tree-menu button[data-act="delete"] { color: var(--err); }
.at-menu {
  position: fixed; z-index: 80; min-width: 280px; max-width: min(480px, 90vw);
  max-height: 240px; overflow: auto; padding: 4px;
  background: var(--bg-white); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
.at-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left; font: inherit; font-size: 13px;
}
.at-item.on, .at-item:hover { background: var(--bg-hover); }
.at-kind { flex: none; font-size: 12px; color: var(--muted); }
.at-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sess-list, .tree { flex: 1; min-height: 0; overflow: auto; }
.rail-empty { margin: 8px 6px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sess-search {
  position: relative; display: block; margin: 0 4px 10px;
}
.sess-search svg {
  position: absolute; z-index: 1; top: 50%; left: 10px; width: 14px; height: 14px;
  color: #9ca3af; transform: translateY(-50%); pointer-events: none;
}
.sess-search input {
  width: 100%; height: 32px; margin: 0 !important; padding: 0 30px !important;
  border: 1px solid transparent !important; border-radius: 9px !important;
  background: color-mix(in srgb, var(--bg-white) 70%, transparent) !important;
  color: var(--ink); font-size: 12px !important;
}
.sess-search input:focus {
  border-color: color-mix(in srgb, var(--brand-primary) 28%, var(--line)) !important;
  background: var(--bg-white) !important;
}
#panel-files { position: relative; }
#upload-mask {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg-white) 78%, transparent);
}
#upload-mask[hidden] { display: none; }
.upload-box {
  display: grid; justify-items: center; gap: 10px;
  width: min(200px, 82%); color: var(--ink); font-size: 12px; text-align: center;
}
.upload-box .wait-spin { width: 22px; height: 22px; }
.upload-bar {
  width: 100%; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden;
}
.upload-bar i { display: block; height: 100%; width: 0; background: var(--accent); }
#upload-mask[data-mode="done"] .wait-spin,
#upload-mask[data-mode="err"] .wait-spin { display: none; }
#upload-mask[data-mode="err"] { color: var(--err); }
.inst-off { display: grid; gap: 8px; padding: 8px 4px; }
.inst-off p { margin: 0; }
.inst-off .panel-new { justify-self: start; padding-left: 0; }
.sess-row { display: flex; align-items: center; min-height: 54px; border-radius: 10px; }
.sess-row:hover { background: var(--bg-hover); }
.sess-row.on { background: var(--shell-nav-active-bg); }
.sess-row.on .sess-title { color: var(--shell-nav-active-text); font-weight: 600; }
.sess-lead {
  position: relative; flex: none; width: 15px; height: 15px; margin-left: 9px;
}
.sess-spin {
  position: absolute; inset: 1px;
  border: 2px solid var(--accent); border-right-color: transparent;
  border-radius: 50%; opacity: 0;
}
.sess-row.run .sess-spin { opacity: 1; animation: spin .7s linear infinite; }
.sess-ico { color: var(--muted); display: flex; }
.sess-row.on .sess-ico { color: var(--shell-nav-active-text); }
.sess-row.run .sess-ico { opacity: 0; }
.sess-ico svg { width: 15px; height: 15px; display: block; }
.sess {
  flex: 1; min-width: 0;
  display: grid; gap: 2px;
  padding: 7px 6px 7px 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
}
.sess-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-meta { display: flex; align-items: center; gap: 4px; color: #8b919b; font-size: 10px; font-weight: 500; }
.sess-row.on .sess-meta { color: color-mix(in srgb, var(--shell-nav-active-text) 62%, var(--muted)); }
.sess-del {
  flex: none; opacity: 0;
  background: transparent; color: var(--muted);
  border: 0; border-radius: 50%; width: 24px; height: 24px; padding: 0; margin-right: 5px;
  font: 18px/1 var(--font-sans); cursor: pointer;
}
.sess-row:hover .sess-del, .sess-row:focus-within .sess-del { opacity: 1; }
.sess-del:hover { color: var(--err); background: transparent; }
.tree-row {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  padding: 5px 8px 5px 4px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); font: inherit; font-size: 13px;
  cursor: pointer;
}
.tree-row:hover { background: var(--bg-hover); }
.tree-chev { flex: none; width: 10px; color: var(--muted); font-size: 10px; line-height: 1; }
.tree-ico { flex: none; width: 16px; height: 16px; display: flex; }
.tree-ico svg { width: 16px; height: 16px; display: block; }
.tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-kids { padding-left: 12px; }

.pane { flex: 1; overflow: auto; padding: 28px 36px 40px; max-width: none; margin: 0; background: var(--bg-main); }
.stage { flex: 1; display: flex; flex-direction: column; padding: 0; max-width: none; margin: 0; background: var(--bg-white); min-width: 0; }
.chat-split { flex: 1; display: flex; min-width: 0; min-height: 0; }
.chat { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.connection-status {
  position: absolute; z-index: 8; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  background: color-mix(in srgb, var(--bg-white) 92%, transparent); color: var(--muted); font-size: 11px;
}
.connection-dot { width: 6px; height: 6px; border-radius: 50%; background: #d97706; animation: connection-pulse 1.2s ease-in-out infinite; }
.connection-status.ok .connection-dot { background: #2f855a; animation: none; }
@keyframes connection-pulse { 50% { opacity: .35; } }
.thread { position: relative; flex: 1; min-width: 0; overflow-x: hidden; overflow-y: auto; padding: 28px 24px 20px; }
.chat-load {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255, 255, 255, .55);
  color: var(--muted); font-size: 13px;
}
.chat-load[hidden] { display: none; }
.thread.is-loading #msgs,
.thread.is-loading .welcome { opacity: .35; pointer-events: none; }
.welcome { max-width: 680px; margin: 11vh auto 0; animation: rise .45s ease both; }
.welcome-kicker {
  margin: 0 0 10px; font-size: 11px; font-weight: 650; letter-spacing: .16em;
  text-transform: uppercase; color: var(--brand-primary);
}
.welcome h1, .kb-head h1, .card > h1 {
  font-family: var(--font-display); font-size: 34px; font-weight: 640;
  letter-spacing: -.03em; line-height: 1.15;
}
.welcome h1 { margin: 0 0 12px; }
.welcome p { color: var(--ink); line-height: 1.7; }
.welcome .welcome-lead { max-width: 560px; margin: 0; color: #4b5563; font-size: 15px; }
.starter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 26px; }
.starter {
  display: flex; align-items: center; gap: 12px; min-width: 0; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-white);
  color: var(--ink); text-align: left; box-shadow: none;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
.starter:hover {
  border-color: color-mix(in srgb, var(--brand-primary) 28%, var(--line));
  background: #fffaf6; box-shadow: 0 8px 24px rgba(88, 55, 30, .07); transform: translateY(-1px);
}
.starter-icon {
  display: grid; flex: none; width: 34px; height: 34px; place-items: center;
  border-radius: 10px; background: var(--brand-primary-faint); color: var(--brand-primary-pressed);
  font-family: var(--font-display); font-size: 15px; font-weight: 640;
}
.starter > span:last-child { display: grid; min-width: 0; gap: 2px; }
.starter strong { font-size: 13px; font-weight: 650; }
.starter small { overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.welcome .welcome-hint { margin-top: 16px; color: var(--muted); font-size: 12px; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
#msgs { width: 100%; max-width: 720px; margin: 0 auto; display: grid; gap: 10px; min-width: 0; }
#msgs > * { min-width: 0; max-width: 100%; }
.bubble { padding: 10px 14px; border-radius: 12px; overflow-wrap: anywhere; word-break: break-word; }
.bubble.user {
  justify-self: end; max-width: 80%;
  background: #FFF3EB; color: var(--ink);
  white-space: pre-wrap;
}
.bubble-text { white-space: pre-wrap; }
.wait {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--bg-main); color: var(--muted); font-size: 13px;
}
.wait-dots { display: flex; align-items: center; gap: 6px; padding: 18px 2px 8px; }
.wait-dots i {
  display: block; flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: wait-dot 1s ease-in-out infinite;
}
.wait-dots i:nth-child(2) { animation-delay: .16s; }
.wait-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes wait-dot {
  0%, 70%, 100% { opacity: .25; transform: translateY(0) scale(.85); }
  35% { opacity: 1; transform: translateY(-4px) scale(1); }
}
.boot { margin: 0 auto 12px; max-width: 720px; }
.inst-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 720px; margin: 0 auto 12px; padding: 10px 14px;
  border-radius: 10px; background: var(--bg-main);
}
.inst-hint p { margin: 0; color: var(--muted); font-size: 13px; }
.inst-hint button { flex-shrink: 0; padding: 6px 14px; font-size: 13px; }
.composer.dim { opacity: .5; pointer-events: none; }
.wait-spin {
  width: 14px; height: 14px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.answer { line-height: 1.75; overflow-wrap: anywhere; }
.answer p { margin: 0 0 8px; }
.answer p:last-child { margin-bottom: 0; }
.answer h4 { margin: 12px 0 6px; font-size: 14px; }
.answer ul { margin: 0 0 8px; padding-left: 20px; }
.answer code { background: var(--bg-selected); padding: 1px 5px; border-radius: 4px; font-size: 13px; overflow-wrap: anywhere; }
.answer .md-code {
  background: var(--sidebar-bg); border-radius: 8px; padding: 10px 12px;
  margin: 6px 0 10px; max-width: 100%; overflow-x: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 13px; line-height: 1.5;
}
.answer a { color: var(--accent); }
.answer .md-table-scroll {
  margin: 10px 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-white);
}
.answer table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}
.answer th, .answer td {
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
  vertical-align: top;
  padding: 8px 12px;
  border: 1px solid var(--line);
}
.answer thead th {
  font-weight: 600;
  background: var(--bg-main);
}
.answer tbody tr:nth-child(even) td { background: var(--bg-main); }
.step { background: var(--bg-main); border-radius: 10px; max-width: 100%; }
.step summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; list-style: none;
  font-size: 13px; line-height: 1.4;
}
.step summary::-webkit-details-marker { display: none; }
.step-ico { width: 16px; height: 16px; flex: none; color: var(--muted); display: flex; }
.step-ico svg { width: 16px; height: 16px; }
.step[data-kind="think"] .step-ico { color: #c2410c; }
.step[data-state="run"] .step-ico svg { animation: spin .9s linear infinite; }
.step-label { flex: none; font-weight: 600; color: var(--ink); }
.tool-pill {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start;
  max-width: 100%; min-width: 0;
  padding: 5px 12px 5px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-main);
  color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.tool-pill:hover { background: var(--bg-hover); }
.tool-pill.is-on { background: var(--bg-selected); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tool-pill[data-state="run"] { border-style: dashed; }
.tool-pill[data-state="err"] { color: var(--err); }
.tool-pill-ico { width: 16px; height: 16px; flex: none; color: var(--muted); display: flex; }
.tool-pill-ico svg { width: 16px; height: 16px; }
.tool-pill[data-state="run"] .tool-pill-ico { color: var(--accent); }
.tool-pill[data-state="run"] .tool-pill-ico svg { animation: spin .9s linear infinite; }
.tool-pill[data-state="err"] .tool-pill-ico { color: var(--err); }
.tool-pill-label { flex: none; font-weight: 600; }
.tool-pill-hint { min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-pill-state { flex: none; font-size: 12px; color: var(--muted); }
.tool-drawer {
  width: min(400px, 42vw); flex: none; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  margin: 12px 12px 12px 0; border-radius: 12px; background: var(--bg-main);
}
.tool-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 12px;
}
.tool-drawer-kicker { margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.tool-drawer-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.tool-drawer-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tool-drawer-close {
  flex: none; padding: 6px 12px; border-radius: 8px;
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.tool-drawer-close:hover { background: var(--bg-hover); }
.tool-drawer-body { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 18px; display: grid; gap: 16px; }
.tool-drawer-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.tool-drawer-body pre {
  margin: 0; padding: 12px; border-radius: 8px; background: var(--bg-white);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink);
}
@keyframes spin { to { transform: rotate(360deg); } }
.step-hint { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-state { flex: none; font-size: 12px; color: var(--muted); }
.step[data-state="run"] .step-state { color: var(--accent); }
.step[data-state="err"] .step-state { color: var(--err); }
.step-body {
  margin: 0; padding: 0 12px 10px; border: 0;
  max-height: 240px; overflow-x: hidden; overflow-y: auto;
  color: var(--muted); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; background: none;
}
.step[data-state="run"] summary { position: relative; overflow: hidden; }
.step[data-state="run"] summary::after {
  content: ""; position: absolute; inset-block: 0; left: 0; width: 240px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg-white) 70%, transparent) 55%, transparent);
  animation: think-sweep 2.6s ease-out infinite; pointer-events: none;
}
@keyframes think-sweep { 0% { left: -240px; } 90%, 100% { left: 100%; } }
.ask-card {
  max-width: 720px; width: min(720px, calc(100% - 48px)); min-width: 0;
  margin: 0 auto 12px; padding: 14px 16px 12px;
  background: var(--bg-white); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
}
.ask-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ask-kicker { margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.ask-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.ask-q { margin: 14px 0 0; }
.ask-q-title { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.ask-q-detail { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.ask-opts { display: grid; gap: 8px; }
.ask-opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; text-align: left;
  background: var(--bg-main); color: var(--ink); border: 1px solid var(--line);
}
.ask-opt.on { background: var(--bg-selected); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.ask-opt small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.ask-custom { margin-top: 8px; }
.ask-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.ask-card .ask-err { margin: 8px 0 0; padding: 0; }
.composer {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end;
  max-width: 720px; width: min(720px, calc(100% - 48px)); min-width: 0; margin: 12px auto 20px;
  padding: 10px 12px; background: var(--bg-white);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--brand-primary) 40%, var(--line)); }
.composer textarea {
  flex: 1 1 100%; min-width: 0; border: 0; resize: none; min-height: 44px; max-height: 160px;
  padding: 8px 4px; outline: none; background: transparent; font: inherit;
}
.composer-bar { display: flex; align-items: center; gap: 10px; width: 100%; }
.composer-setting {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0; padding: 2px 4px 2px 8px;
  border-radius: 999px; background: var(--bg-main); color: var(--muted);
}
.composer-setting-key { flex: none; font-size: 10px; font-weight: 600; color: #9ca3af; }
.composer-model {
  width: auto; max-width: 160px; margin: 0 !important; padding: 4px 22px 4px 2px !important;
  border: 0 !important; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.composer-fixed { padding: 4px 7px 4px 2px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.composer-bar button { margin-left: auto; flex-shrink: 0; }
.composer-bar button.stop {
  background: transparent; color: var(--err); border: 1px solid var(--line);
}
.hit { margin-top: 12px; padding: 16px; }
.card {
  background: var(--bg-white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: var(--shadow);
  animation: rise .4s ease both;
}
body:not(.shell) {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -10%, #FFE9D9 0%, transparent 55%),
    radial-gradient(700px 380px at 110% 0%, #FFF3EB 0%, transparent 50%),
    var(--bg-main);
}
body:not(.shell) main { max-width: 420px; }
.card.auth h1 { font-size: 32px; }
.top .brand { font-family: var(--font-display); color: var(--brand-primary); }
h1 { margin: 0 0 8px; font-size: 26px; }
.hint { margin: 0 0 22px; color: var(--muted); }
label { display: block; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
input:not([hidden]):not([type="checkbox"]):not([type="file"]), select {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; font: inherit; color: var(--ink);
}
input:focus, select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand-primary) 45%, var(--line));
}
[hidden] { display: none !important; }
button, .btn {
  appearance: none; border: 0; border-radius: 999px;
  background: var(--brand-primary); color: var(--accent-ink);
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s ease, transform .12s ease;
}
button:hover, .btn:hover { background: var(--brand-primary-hover); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--bg-hover); }
button.busy {
  display: inline-flex; align-items: center; gap: 8px;
  opacity: .85; cursor: wait;
}
button.busy::before {
  content: ""; width: 14px; height: 14px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
button:disabled { opacity: .4; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.foot { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.err { color: var(--err); font-size: 13px; max-width: 720px; margin: 0 auto 16px; padding: 0 24px; }
.meta { display: grid; gap: 10px; margin: 0 0 18px; }
.meta div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0 0 22px; }
.admin-form button { align-self: end; justify-self: start; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 12px 10px; text-align: left; }
.admin-table thead { color: var(--muted); font-size: 12px; font-weight: 600; }
.admin-table tbody tr { transition: background .12s ease; }
.admin-table tbody tr:hover td { background: #FFFBF7; }
.admin-table td { border-bottom: 1px solid var(--line); }
.admin-ops { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-ops button { padding: 6px 12px; font-size: 13px; }
.admin-err { margin-top: 4px; max-width: 360px; color: var(--err); font-size: 12px; line-height: 1.4; }
.ask-mask {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(15, 23, 42, .35);
  display: flex; align-items: center; justify-content: center;
}
.ask-box {
  width: min(360px, calc(100% - 32px));
  background: var(--bg-white); border-radius: 14px;
  padding: 20px 20px 16px; box-shadow: var(--shadow);
}
.ask-box p { margin: 0 0 16px; font-size: 15px; line-height: 1.55; }
.ask-ops { display: flex; justify-content: flex-end; gap: 8px; }
.ask-ops button { padding: 8px 14px; font-size: 13px; }
.preview-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .35);
  display: flex; align-items: center; justify-content: center;
  padding: 4vh 4vw;
}
.preview-box {
  width: min(880px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--bg-white); border-radius: 14px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, .08), 0 16px 48px rgba(15, 23, 42, .12);
  overflow: hidden;
}
.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.preview-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.preview-title strong { font-size: 15px; }
.preview-title span {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-ops { display: flex; gap: 8px; flex-shrink: 0; }
.preview-ops .ghost, .preview-ops .btn.ghost {
  padding: 6px 14px; font-size: 13px;
  background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
}
.preview-md { padding: 20px 24px; overflow: auto; flex: 1; min-width: 0; }
.preview-code {
  margin: 0; padding: 18px; overflow: auto; flex: 1;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-main); white-space: pre-wrap; word-break: break-word;
}
.preview-media { padding: 18px; overflow: auto; text-align: center; }
.preview-media img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.preview-video { background: #111; }
.preview-media video { display: block; width: 100%; max-height: 70vh; background: #111; }
.preview-none { padding: 24px 18px; }
.preview-box.wide { width: min(1100px, 100%); }
.preview-frame {
  flex: 1; min-height: 70vh; width: 100%; border: 0; background: var(--bg-main);
}
.sheet-wrap { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: hidden; }
.sheet-tabs {
  display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto;
  flex-shrink: 0; border-bottom: 1px solid var(--line); background: var(--bg-main);
}
.sheet-tab {
  padding: 6px 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; line-height: 1.4;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.sheet-tab.on { background: var(--bg-white); color: var(--ink); font-weight: 600; }
.sheet-pane { overflow: auto; flex: 1; }
.sheet { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.sheet td {
  padding: 5px 10px; border: 1px solid var(--line); white-space: nowrap;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.sheet tr:first-child td { font-weight: 600; background: var(--bg-main); }

.kb-page { max-width: none; width: 100%; animation: rise .4s ease both; }
.kb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.kb-head h1 { margin: 0; font-size: 22px; }
.kb-head .hint { margin-bottom: 0; max-width: 640px; line-height: 1.65; }
.kb-head-ops { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.kb-tool-btn, .kb-primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; box-sizing: border-box; padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; line-height: 1; text-decoration: none;
}
.kb-tool-btn { color: var(--ink); background: var(--bg-white); border: 1px solid var(--line); }
.kb-tool-btn:hover { color: var(--brand-primary); border-color: color-mix(in srgb, var(--brand-primary) 35%, var(--line)); background: #fffaf6; }
.kb-primary-btn { border: 1px solid var(--brand-primary); color: white; background: var(--brand-primary); }
.kb-page .kb-primary-btn:hover { border-color: var(--brand-primary-hover); background: var(--brand-primary-hover); }
.kb-tool-btn svg, .kb-primary-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kb-back { display: inline-block; margin-bottom: 6px; color: var(--brand-primary); text-decoration: none; font-size: 13px; font-weight: 600; }
.kb-back:hover { color: var(--brand-primary-hover); }
.kb-search { display: flex; gap: 10px; margin: 20px 0 16px; max-width: 560px; }
.kb-search input { margin: 0; background: var(--bg-white); }
.kb-search button { flex: none; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.kb-card {
  padding: 20px 18px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-white); cursor: pointer; min-height: 124px;
  display: flex; flex-direction: column;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.kb-card:hover {
  border-color: color-mix(in srgb, var(--brand-primary) 35%, var(--line));
  box-shadow: var(--shadow);
  background: color-mix(in srgb, var(--brand-primary) 3%, var(--bg-white));
}
.kb-card.static { cursor: default; min-height: 148px; }
.kb-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kb-card-top strong { font-size: 16px; letter-spacing: -.01em; }
.kb-card p {
  margin: 8px 0 14px; color: #4b5563; font-size: 13px; line-height: 1.55; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kb-card-meta {
  display: flex; justify-content: space-between; color: var(--muted); font-size: 12px;
  padding-top: 8px; border-top: 1px solid #f3f4f6;
}
.kb-card-meta b { color: var(--ink); font-weight: 650; }
.kb-more {
  padding: 2px 8px; border-radius: 6px; background: transparent; color: var(--muted);
  line-height: 1; font-size: 16px;
}
.kb-more:hover { background: var(--shell-nav-hover-bg); color: var(--shell-nav-hover-text); }
.kb-empty { grid-column: 1 / -1; color: var(--muted); padding: 48px 0; text-align: center; }
.kb-hit {
  display: block; padding: 12px 14px; margin-bottom: 8px; border-radius: 12px;
  background: var(--bg-white); color: inherit; text-decoration: none; border: 1px solid var(--line);
}
.kb-hit:hover { border-color: color-mix(in srgb, var(--brand-primary) 30%, var(--line)); background: #FFFBF7; }
.kb-hit span { margin-left: 8px; color: var(--muted); font-size: 12px; }
.kb-hit p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.kb-detail {
  display: flex; min-height: 560px; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-white); overflow: hidden;
}
.kb-tree { width: 220px; flex: none; padding: 0 10px 12px; background: var(--sidebar-bg); border-right: 1px solid var(--line); }
.kb-tree-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 8px; color: var(--muted); font-size: 12px; }
.kb-tree-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
  color: var(--muted); background: transparent;
}
.kb-tree-add svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.kb-page .kb-tree-add:hover { color: var(--brand-primary); background: var(--shell-nav-hover-bg); }
.kb-folder { padding-left: calc(var(--d) * 14px); }
.kb-folder-btn {
  width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px;
  background: transparent; color: var(--ink); font-size: 13px;
}
a.kb-folder-btn { display: block; text-decoration: none; box-sizing: border-box; }
.kb-folder-btn:hover { background: var(--shell-nav-hover-bg); color: var(--shell-nav-hover-text); }
.kb-folder-btn.on { background: var(--shell-nav-active-bg); color: var(--shell-nav-active-text); font-weight: 600; }
.kb-tree-ops { display: grid; gap: 6px; margin-top: 12px; }
.kb-tree-ops button { padding: 6px 10px; font-size: 12px; }
.kb-docs { flex: 1; min-width: 0; padding: 0 8px 20px; overflow: auto; }
.kb-docs-head { padding: 12px 8px; color: var(--muted); font-size: 13px; }
.kb-table a { color: var(--ink); text-decoration: none; font-weight: 550; }
.kb-table a:hover { color: var(--brand-primary); }
.kb-table .ghost { padding: 4px 10px; font-size: 12px; }
.kb-table th:first-child, .kb-table td:first-child { width: 28px; padding-right: 0; }
.kb-expand {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px;
  color: var(--muted); background: transparent;
}
.kb-expand svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; transition: transform .18s ease; }
.kb-expand.open svg { transform: rotate(45deg); }
.kb-page .kb-expand:not(:disabled):hover { color: var(--brand-primary); background: var(--shell-nav-hover-bg); }
.kb-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.kb-actions a, .kb-actions button {
  min-height: 0; padding: 3px 0; border: 0; border-radius: 4px;
  background: transparent; color: var(--brand-primary); font: inherit; font-size: 12px; font-weight: 550; line-height: 1.3; cursor: pointer;
}
.kb-actions a:hover, .kb-page .kb-actions button:hover { color: var(--brand-primary-hover); background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.kb-actions .kb-action-danger { color: #a94c3b; }
.kb-page .kb-actions .kb-action-danger:hover { color: #873829; background: transparent; }
.kb-status { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.kb-status.ok { color: #26734d; background: #dff3e8; }
.kb-status.bad { color: #a33b20; background: #fde6de; }
.kb-preview-row td { background: #fffaf6; }
.kb-seg-preview-list { display: grid; gap: 8px; padding: 8px 0; }
.kb-seg-preview-list article { padding: 10px 12px; border-radius: 8px; background: #f7f7f5; }
.kb-seg-preview-list small { color: var(--muted); }
.kb-seg-preview-list p { margin: 6px 0 0; line-height: 1.55; }
.kb-body {
  margin-top: 8px; padding: 22px 24px; border-radius: 14px;
  background: var(--bg-white); border: 1px solid var(--line);
  white-space: pre-wrap; line-height: 1.75;
}
.kb-prompt-input { margin: 0 0 14px; }
.kb-create label { margin-bottom: 10px; }
.kb-import { width: min(420px, calc(100% - 32px)); }
.kb-import input[type=file] { margin: 8px 0 12px; }
.kb-seg-list { display: grid; gap: 12px; padding-bottom: 24px; }
.kb-seg-card { position: relative; padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-white); }
.kb-seg-card:hover { border-color: color-mix(in srgb, var(--brand-primary) 30%, var(--line)); box-shadow: var(--shadow); }
.kb-seg-meta { margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.kb-seg-content { padding-right: 100px; color: var(--ink); font-size: 14px; line-height: 1.7; }
.kb-seg-content > :first-child { margin-top: 0; }
.kb-seg-content > :last-child { margin-bottom: 0; }
.kb-seg-actions { position: absolute; top: 10px; right: 12px; display: flex; gap: 4px; opacity: 0; }
.kb-seg-card:hover .kb-seg-actions { opacity: 1; }
.kb-seg-actions button { padding: 3px 7px; background: transparent; color: var(--brand-primary); font-size: 12px; }
.kb-source-modal { width: min(760px, calc(100% - 32px)); }
.kb-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kb-source { max-height: 65vh; overflow: auto; padding: 16px; border-radius: 8px; background: var(--bg-main); line-height: 1.7; }
.kb-segment-modal { width: min(680px, calc(100% - 32px)); }
.kb-segment-modal textarea { width: 100%; box-sizing: border-box; margin: 14px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; line-height: 1.6; resize: vertical; }
.kb-graph-summary { display: flex; align-items: center; gap: 28px; margin-bottom: 12px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-white); }
.kb-graph-summary div { display: grid; }
.kb-graph-summary strong { font-size: 22px; }
.kb-graph-summary span, .kb-graph-summary p { color: var(--muted); font-size: 12px; }
.kb-graph-summary p { margin-left: auto; }
.kb-graph-notice { margin-bottom: 12px; padding: 12px 16px; border-radius: 8px; background: #fff1f0; color: #b42318; font-size: 13px; }
.kb-graph-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-white); }
.kb-graph-toolbar > input { width: 210px; height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; }
.kb-graph-toolbar > input:focus { border-color: var(--brand-primary); }
.kb-graph-toolbar > label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.kb-graph-legend { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.kb-graph-legend button { display: flex; align-items: center; gap: 5px; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.kb-graph-legend button:hover, .kb-graph-legend button.active { background: var(--bg-soft); color: var(--ink); }
.kb-graph-legend i { width: 7px; height: 7px; border-radius: 50%; }
.kb-graph-canvas { min-height: 560px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: radial-gradient(circle at 1px 1px, #d9dfe7 1px, transparent 0); background-size: 22px 22px; }
.kb-graph-canvas svg { display: block; width: 100%; min-height: 560px; cursor: grab; touch-action: none; }
.kb-graph-canvas svg:active { cursor: grabbing; }
.kb-graph-canvas line { stroke: #94a3b8; stroke-width: .8; stroke-opacity: .45; }
.kb-graph-canvas circle { stroke: rgba(255,255,255,.9); stroke-width: 2; filter: drop-shadow(0 2px 3px rgba(15,23,42,.14)); cursor: pointer; }
.kb-graph-canvas text { fill: var(--ink); font-size: 11px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.kb-graph-canvas .kg-edge-label { display: none; fill: var(--muted); font-size: 9px; paint-order: stroke; stroke: white; stroke-width: 3px; }
.kb-graph-canvas svg.show-labels .kg-edge-label { display: block; }
.kb-graph-canvas .dim { opacity: .1; }
.kb-graph-empty { display: grid; min-height: 560px; place-items: center; color: var(--muted); font-size: 13px; }

.plugin-page { width: 100%; max-width: none; }
#plugin-root { width: 100%; }
.plugin-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.plugin-head h1 { margin: 2px 0 6px; font-size: 26px; letter-spacing: -.03em; }
.plugin-head p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.plugin-install { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(420px, 1.4fr); gap: 10px 24px; align-items: center; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-white); }
.plugin-install > div { display: grid; gap: 3px; }
.plugin-install > div strong { font-size: 14px; }
.plugin-install > div span, .plugin-security { color: var(--muted); font-size: 11px; }
.plugin-install form { display: flex; gap: 8px; }
.plugin-install input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.plugin-install input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(249,115,22,.1); }
.plugin-security { grid-column: 2; margin: 0; }
#plugin-error { margin: 12px 0 0; }
.plugin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.plugin-card { display: flex; gap: 13px; min-height: 132px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-white); transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.plugin-card:hover { transform: translateY(-1px); border-color: #d7c8bc; box-shadow: 0 8px 20px rgba(65,44,30,.06); }
.plugin-card-icon { display: grid; flex: 0 0 34px; height: 34px; place-items: center; border-radius: 9px; background: #fff1e8; color: var(--brand-primary); font: 700 20px Georgia, serif; }
.plugin-card-body { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.plugin-card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plugin-card-title strong { overflow: hidden; font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.plugin-card-body > p { margin: 7px 0 0; overflow: hidden; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.plugin-status { flex: none; padding: 3px 7px; border-radius: 99px; background: #ecfdf3; color: #067647; font-size: 10px; }
.plugin-status.installing { background: #eff8ff; color: #175cd3; }
.plugin-status.failed { background: #fef3f2; color: #b42318; }
.plugin-card-error { margin-top: 7px; color: #b42318; font-size: 10px; line-height: 1.4; }
.plugin-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 14px; color: var(--muted); font-size: 10px; }
.plugin-switch { display: flex; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.plugin-switch i { position: relative; width: 30px; height: 17px; border-radius: 99px; background: #cbd5e1; transition: background .18s ease; }
.plugin-switch i::after { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); content: ""; transition: transform .18s ease; }
.plugin-switch.on i { background: var(--brand-primary); }
.plugin-switch.on i::after { transform: translateX(13px); }
.plugin-switch b { font-weight: 500; }
.plugin-switch:disabled { cursor: not-allowed; opacity: .5; }
.plugin-empty, .plugin-loading { grid-column: 1 / -1; display: grid; min-height: 220px; place-items: center; align-content: center; gap: 7px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; }
.plugin-empty strong { color: var(--ink); font-size: 14px; }
@media (max-width: 1000px) {
  .plugin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plugin-install { grid-template-columns: 1fr; }
  .plugin-security { grid-column: 1; }
}

.dp-page { max-width: 1120px; }
.dp-tabs { display: flex; gap: 6px; margin: 18px 0 16px; }
.dp-tabs a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.dp-tabs a:hover { background: var(--shell-nav-hover-bg); color: var(--shell-nav-hover-text); }
.dp-tabs a.on { background: var(--shell-nav-active-bg); color: var(--shell-nav-active-text); }
.dp-sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.dp-tag {
  display: inline-block; margin: 0 4px 2px 0; padding: 1px 7px;
  border-radius: 999px; background: var(--bg-hover); color: var(--muted); font-size: 11px; font-weight: 600;
}
.dp-tag.warn { background: #FFE9D9; color: var(--brand-primary-pressed); }
.dp-sheet { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-white); }
.dp-sheet .sheet { min-width: 100%; }
.dp-job-ops { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dp-job-ops button { padding: 6px 12px; font-size: 12px; }
.dp-job-res { color: var(--muted); font-size: 12px; white-space: pre-wrap; background: #fafafa; }

.skill-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.skill-card { min-width: 0; }
.sk-form { max-width: 880px; display: grid; gap: 8px; }
.skill-form-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.skill-form-row small, .skill-help { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.sk-form textarea { display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; font-size: 13px; line-height: 1.55; resize: vertical; }
.sk-form .skill-body { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sk-form textarea:focus { outline: none; border-color: color-mix(in srgb, var(--brand-primary) 45%, var(--line)); }
.skill-field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.skill-wand-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; color: var(--brand-primary); background: color-mix(in srgb, var(--brand-primary) 12%, white); font-size: 12px; font-weight: 600; }
.skill-wand-btn:hover { background: color-mix(in srgb, var(--brand-primary) 20%, white); }
.skill-wand-btn.is-busy { animation: skill-wand-pulse 1.2s ease-in-out infinite; }
.skill-wand-btn:disabled { opacity: .45; cursor: not-allowed; }
@keyframes skill-wand-pulse { 50% { opacity: .55; } }
.sk-switch { display: flex; align-items: center; gap: 8px; margin: 8px 0 16px; color: var(--ink); font-size: 14px; }
.sk-switch input { width: auto; margin: 0; }
.kb-card-meta .ghost { padding: 4px 10px; font-size: 12px; margin-left: 6px; }
.kb-body.answer { max-width: none; }
@media (max-width: 1280px) { .skill-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .skill-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .skill-grid { grid-template-columns: 1fr; }
  .skill-form-row { grid-template-columns: 1fr; }
  .side-panel { width: 246px; }
  .side-panel .panel { min-width: 222px; }
  .thread { padding-inline: 16px; }
  .welcome { margin-top: 7vh; }
  .welcome h1 { font-size: 30px; }
  .starter-grid { grid-template-columns: 1fr; }
  .starter:nth-child(n + 4) { display: none; }
  .composer { width: calc(100% - 24px); margin-bottom: 12px; }
  .composer-setting-key { display: none; }
  .composer-setting { padding-left: 5px; }
  .composer-model { max-width: 112px; }
  .tool-drawer { position: absolute; inset: 8px; z-index: 20; width: auto; margin: 0; box-shadow: var(--shadow-lg); }
}
