:root {
  --bg: #f6f4ec;
  --bg-elev: #ffffff;
  --bg-subtle: #ede9dc;
  --ink: #1b2824;
  --ink-muted: #52635d;
  --brand: #26544a;
  --brand-strong: #1b3f37;
  --brand-soft: rgba(38, 84, 74, 0.1);
  --accent: #b85624;
  --accent-soft: rgba(184, 86, 36, 0.12);
  --border: #d8d2c2;
  --shadow: 0 10px 28px rgba(24, 42, 37, 0.07);
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", Georgia, serif;
}

html[data-theme="dark"] {
  --bg: #0f1715;
  --bg-elev: #172320;
  --bg-subtle: #1f2e2a;
  --ink: #eae6dc;
  --ink-muted: #9eb0a9;
  --brand: #54a895;
  --brand-strong: #72c4b1;
  --brand-soft: rgba(84, 168, 149, 0.16);
  --accent: #e58550;
  --accent-soft: rgba(229, 133, 80, 0.16);
  --border: #2a3d38;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.6; overflow-x: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand-wrap { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #26544a, #3d7a6c);
  color: #fff; font-weight: 700; font-family: var(--serif);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
  flex-shrink: 0;
}
.brand-title { font-family: var(--serif); font-weight: 700; font-size: 1.08rem; letter-spacing: 0.02em; }
.brand-sub { font-size: 0.74rem; color: var(--ink-muted); display: block; }

.nav-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-tab:hover { color: var(--ink); background: var(--bg-subtle); }
.nav-tab.active {
  color: var(--brand-strong);
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 38%, transparent);
}

.top-actions { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--ink); font-size: 0.83rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-ai {
  background: linear-gradient(135deg, #26544a 0%, #b85624 100%);
  color: #fff; border: none; box-shadow: 0 4px 12px rgba(184, 86, 36, 0.24);
}
.btn-ai:hover { opacity: 0.94; color: #fff; }

.container { max-width: 1360px; margin: 0 auto; padding: 22px 20px 64px; }

.hero-card {
  background: linear-gradient(135deg, #1d4038 0%, #2d5d52 62%, #3c695b 100%);
  color: #f6f3eb;
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 22px;
}
.hero-badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.24); color: #f6f3eb;
}
.hero-card h1 { margin: 0 0 10px; font-family: var(--serif); font-size: clamp(1.55rem, 2.5vw, 2.15rem); line-height: 1.25; }
.hero-card p { margin: 0 0 16px; color: #dce6e1; font-size: 0.94rem; max-width: 52rem; }
.domain-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.domain-chip {
  padding: 4px 10px; border-radius: 7px; font-size: 0.77rem;
  background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.18); color: #eef2ee;
}
.hero-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-btns .btn-light { background: #fdfbf7; color: #1b3f37; border-color: #fdfbf7; }
.hero-btns .btn-ghost { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.3); }

.clock-panel {
  background: rgba(12, 26, 23, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.clock-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.76rem; color: #b9d2ca; }
.clock-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.clock-cell { background: rgba(255, 255, 255, 0.07); border-radius: 9px; padding: 8px 10px; }
.clock-cell.wide { grid-column: 1 / -1; }
.clock-label { font-size: 0.7rem; color: #b6cec6; display: block; }
.clock-val { font-family: var(--mono); font-size: 0.92rem; font-weight: 600; color: #fff; word-break: break-all; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-num { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--brand); line-height: 1.15; }
.kpi-title { font-size: 0.86rem; font-weight: 600; margin-top: 4px; }
.kpi-desc { font-size: 0.77rem; color: var(--ink-muted); margin-top: 4px; }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 26px 0 14px;
}
.section-head h2 { margin: 0; font-family: var(--serif); font-size: 1.28rem; }
.section-head p { margin: 4px 0 0; font-size: 0.86rem; color: var(--ink-muted); }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.card h3 { margin: 0; font-size: 1.02rem; line-height: 1.4; }
.card p { margin: 0; font-size: 0.86rem; color: var(--ink-muted); }
.tag {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 0.73rem; font-weight: 600; background: var(--brand-soft); color: var(--brand-strong);
  width: fit-content;
}
.tag.amber { background: var(--accent-soft); color: var(--accent); }

/* MCP Workbench */
.mcp-layout {
  display: grid;
  grid-template-columns: 260px minmax(260px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.panel-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.pack-list { display: flex; flex-direction: column; gap: 4px; max-height: 680px; overflow-y: auto; }
.pack-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; padding: 7px 10px; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--ink);
  font-size: 0.83rem; cursor: pointer;
}
.pack-btn:hover { background: var(--bg-subtle); }
.pack-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); font-weight: 600; }
.pack-char {
  width: 22px; height: 22px; border-radius: 6px; background: var(--bg-subtle);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.74rem; font-weight: 700;
}

.search-input, .form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-size: 0.85rem; font-family: inherit;
}
.form-textarea { font-family: var(--mono); min-height: 92px; resize: vertical; }

.tool-list { display: flex; flex-direction: column; gap: 6px; max-height: 620px; overflow-y: auto; margin-top: 10px; }
.tool-item {
  width: 100%; text-align: left; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--ink); cursor: pointer;
}
.tool-item:hover { border-color: var(--brand); }
.tool-item.active { border-color: var(--brand); background: var(--brand-soft); }
.tool-item-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.83rem; font-weight: 600; }
.tool-item-desc { font-size: 0.76rem; color: var(--ink-muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.param-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.param-field label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 3px; }
.param-field small { display: block; font-size: 0.72rem; color: var(--ink-muted); margin-bottom: 4px; }
.code-pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-family: var(--mono); font-size: 0.8rem; overflow-x: auto;
  white-space: pre-wrap; word-break: break-word; margin: 10px 0 0;
}

/* Knowledge Tables */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev); }
table.std-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
table.std-table th, table.std-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.std-table th { background: var(--bg-subtle); font-weight: 700; white-space: nowrap; }

/* Floating AI Capsule & Drawer */
.ai-fab {
  position: fixed; right: 20px; bottom: 22px; z-index: 60;
  padding: 11px 18px; border-radius: 999px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #26544a 0%, #b85624 100%);
  color: #fff; font-weight: 700; font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(27, 63, 55, 0.35);
}
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(10, 18, 16, 0.48); z-index: 80;
}
.ai-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(500px, 100vw);
  background: var(--bg-elev); border-left: 1px solid var(--border); z-index: 90;
  display: flex; flex-direction: column; box-shadow: -12px 0 36px rgba(0, 0, 0, 0.22);
}
.drawer-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.drawer-body { padding: 14px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.onboard-card {
  background: linear-gradient(135deg, var(--brand-soft), var(--accent-soft));
  border: 1px solid var(--brand); border-radius: 12px; padding: 14px;
}
.chat-log { display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { padding: 10px 13px; border-radius: 12px; font-size: 0.85rem; border: 1px solid var(--border); background: var(--bg); }
.chat-bubble.user { background: var(--brand-soft); border-color: var(--brand); align-self: flex-end; max-width: 90%; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg-subtle); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

[hidden] { display: none !important; }

@media (max-width: 1060px) {
  .hero-card { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mcp-layout { grid-template-columns: 1fr; }
  .pack-list { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .pack-btn { width: auto; }
}

@media (max-width: 640px) {
  .kpi-strip, .grid-3, .grid-2, .param-grid { grid-template-columns: 1fr; }
  .hero-card { padding: 18px; }
  .topbar-inner { padding: 10px 14px; }
  .container { padding: 16px 14px 68px; }
}
