:root {
  color-scheme: light;
  --canvas: #edf0f1;
  --surface: #ffffff;
  --surface-muted: #f6f8f8;
  --ink: #182326;
  --muted: #667477;
  --line: #d6dfe0;
  --accent: #0f6b78;
  --accent-soft: #dceff0;
  --warm: #b6542d;
  --code-bg: #f4f5f7;
  --code-ink: #1e293b;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  color: var(--ink);
  background: var(--canvas);
  font: 15px/1.5 Inter, "Microsoft YaHei", system-ui, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

/* 真正的 100% 宽度全屏 3 栏弹性布局 */
.workspace {
  display: flex !important;
  width: 100% !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* 第一列：左侧固定边栏 (220px) */
.sidebar {
  width: 220px !important;
  min-width: 220px !important;
  max-width: 220px !important;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 12px;
  background: #203438;
  color: #edf7f5;
  border-right: 1px solid #29464a;
  overflow-y: auto;
  flex-shrink: 0;
}

.brand {
  padding: 0 10px 14px;
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
}

.environment-switch {
  margin: 0 10px 14px;
  padding: 6px 10px;
  border: 1px solid #426064;
  border-radius: 4px;
  background: #17282b;
  color: #73d1c8;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.category-list { display: grid; gap: 3px; }

.category-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 0;
  border-left: 3px solid transparent;
  color: #c8dad8;
  text-align: left;
  background: transparent;
  font-size: 14px;
}

.category-button:hover { background: #2a484b; color: #ffffff; }
.category-button.active { border-left-color: #73d1c8; color: #ffffff; background: #2b5154; font-weight: 600; }
.category-count { color: #9fbcba; text-align: right; font-size: 12px; }

/* 第二列：中间函数列表 (占剩余空间的 52%) */
.function-pane {
  flex: 52 !important;
  min-width: 0 !important;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 80px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.kicker { margin: 0 0 3px; color: var(--accent); font-size: 12px; font-weight: 700; }
h1, h2 { margin: 0; font-weight: 700; line-height: 1.25; }
h1 { font-size: 18px; }
h2 { font-size: 18px; }

.search input {
  width: 210px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  color: var(--ink);
  background: var(--surface-muted);
}
.search input:focus { border-color: var(--accent); background: #ffffff; }

/* 中间滚动区域 */
.function-list {
  display: grid;
  align-content: start;
  gap: 9px;
  overflow-y: auto;
  height: 100%;
  padding: 12px;
  background: var(--surface-muted);
}

.function-card {
  position: relative;
  width: 100%;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
}
.function-card:hover { border-color: #8eb8bd; }
.function-card.active { border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }

.function-card-header {
  margin-bottom: 6px;
}
.function-card strong {
  display: block;
  min-height: 20px;
  margin: 0 56px 0 0;
  color: #263c40;
  font-size: 14px;
  font-weight: 700;
}

.card-code-wrapper {
  position: relative;
  width: 100%;
}

/* 代码 Cell 样式 */
.card-code {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  color: var(--code-ink);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  overflow-x: auto;
  box-sizing: border-box;
  background: var(--code-bg);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  max-height: 80px;
  overflow-y: auto;
  cursor: pointer;
}

/* 第三列：右侧详情栏目 (占剩余空间的 48%) */
.detail-pane {
  flex: 48 !important;
  min-width: 0 !important;
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
  background: var(--surface);
}

.call {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  color: var(--code-ink);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  overflow-x: auto;
  box-sizing: border-box;
  background: var(--code-bg);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  max-height: 140px;
  overflow-y: auto;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text;
}

.copy-card {
  position: absolute;
  z-index: 2;
  top: 9px;
  right: 8px;
  height: 27px;
  padding: 0 8px;
  border: 1px solid #a7c8cb;
  border-radius: 3px;
  color: #175460;
  background: #ffffff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.function-card:hover .copy-card { opacity: 1; pointer-events: auto; }
.copy-card:hover { border-color: var(--accent); background: #f8ffff; }

.detail-header { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.summary { margin: 0; color: #344449; font-size: 13px; }
.source { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 2px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); background: var(--surface-muted); flex-shrink: 0; }
.tab { height: 34px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: 13px; }
.tab:hover { color: var(--ink); }
.tab.active { border-bottom-color: var(--warm); color: var(--ink); font-weight: 700; }

.detail-content {
  overflow-y: auto;
  height: 100%;
  padding: 16px 20px 32px;
}

.detail-prose {
  margin: 0;
  color: #273437;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.detail-table {
  width: 100%;
  margin: 0 0 14px;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 13px;
  table-layout: fixed;
}
.detail-table th, .detail-table td {
  padding: 7px 9px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  word-break: break-all;
  overflow-wrap: anywhere;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.detail-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #294a50;
  background: var(--accent-soft);
  font-weight: 700;
}
.detail-table td:first-child { color: #274f57; }
.detail-table code { color: #174d58; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 600; word-break: break-all; user-select: text !important; -webkit-user-select: text !important; }
.empty { margin: 28px 0; color: var(--muted); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

/* 示例（Example）样式 */
.example-box {
  display: grid;
  gap: 12px;
}
.example-section {
  display: grid;
  gap: 6px;
}
.example-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f6b78;
}
.example-code {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--code-ink);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.result-code {
  background: #1e293b;
  color: #38bdf8;
  border-color: #334155;
  max-height: 280px;
  overflow-y: auto;
}

/* query 专用UI样式 */
.table-extra-info {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}
.table-select-btn {
  padding: 3px 6px;
  border: 1px solid #73b3bd;
  border-radius: 3px;
  color: #0f6b78;
  background: #f0f9fa;
  font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 600;
  text-align: left;
  word-break: break-all;
  transition: all 120ms ease;
}
.table-select-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}
.table-select-btn.active {
  border-color: var(--warm);
  background: var(--warm);
  color: #ffffff;
}
.selected-row {
  background: #f7fcfc;
}
.query-tip {
  font-weight: normal;
  font-size: 11px;
  color: #667477;
  margin-left: 6px;
}

.query-return-box {
  display: grid;
  gap: 12px;
}
.query-return-header {
  padding: 12px 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 4px;
  background: #f4fafb;
}
.query-return-header .badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  margin-bottom: 6px;
}
.selected-table-name {
  display: block;
  font-size: 15px;
  color: #0f6b78;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  margin-bottom: 4px;
  word-break: break-all;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.query-return-header p {
  margin: 0;
  color: #344449;
  font-size: 13px;
}
.query-hint-card {
  padding: 12px 14px;
  border: 1px dashed #a4c9ce;
  border-radius: 4px;
  background: #fcfefe;
  color: #2c494e;
  font-size: 13px;
  line-height: 1.6;
}
