:root {
  color-scheme: light;
  font-family: system-ui, "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #18212b;
  background: #f7f8fa;
  --surface: #fff;
  --canvas: #f7f8fa;
  --subtle: #f0f3f6;
  --ink: #18212b;
  --muted: #526170;
  --line: #dce2e8;
  --outline: #788696;
  --accent: #164dab;
  --accent-active: #133f8e;
  --accent-soft: #e8effe;
  --good: #176343;
  --good-soft: #e8f5ed;
  --warn: #785014;
  --warn-soft: #fff3d9;
  --bad: #a22134;
  --bad-soft: #fcecef;
  --bar-height: 68px;
  --control-radius: 8px;
  --sidebar-width: 228px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); text-underline-offset: .18em; }
a, p, dd, td, th, code { overflow-wrap: anywhere; }
button, a, input, textarea, select, [tabindex] { scroll-margin: calc(var(--bar-height) + 12px) 12px 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 700; line-height: 1.28; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
code { font-size: .875rem; }
pre {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-block-size: 40vh;
  overflow: auto;
  font-size: .875rem;
}
.icon { flex: none; width: 20px; height: 20px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.stack, .field-stack { display: grid; gap: 20px; min-width: 0; }
.field-stack { gap: 16px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions-end { justify-content: flex-end; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 625;
  text-align: center;
  text-decoration: none;
}
.button:hover:not(:disabled) { background: var(--subtle); }
.button:active:not(:disabled) { border-color: var(--ink); background: var(--line); }
.primary { border-color: var(--accent); color: white; background: var(--accent); }
.primary:hover:not(:disabled), .primary:active:not(:disabled) { border-color: var(--accent-active); background: var(--accent-active); }
.danger { color: var(--bad); border-color: var(--bad); }
.danger:hover:not(:disabled), .danger:active:not(:disabled) { background: var(--bad-soft); }
.ghost { border-color: transparent; background: transparent; }
.button:disabled { background: var(--subtle); border-color: var(--line); color: var(--muted); }
.icon-button { width: 44px; padding: 0; }
.danger-text { color: var(--bad); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: fixed;
  z-index: 5;
  left: 10px;
  top: 10px;
}
.skip:not(:focus-visible) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.startup, .auth {
  min-height: 100svh;
  max-width: 480px;
  display: grid;
  align-content: center;
  gap: 18px;
  margin-inline: auto;
  padding: 40px 24px;
}
.auth { gap: 24px; }
.auth > .brand { justify-self: center; }
.auth > .brand .brand-name { font-size: 1.125rem; }
.auth-panel {
  display: grid;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface);
}
.auth-heading h1 { font-size: 1.875rem; }
.auth-actions { display: grid; gap: 16px; }
.auth-panel .primary { width: 100%; min-height: 48px; }
.auth-panel .field input { min-height: 48px; }
.auth-panel .field > small { font-size: .875rem; }
.auth-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.auth-secondary a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.auth-feedback, .auth-panel .form-feedback:not(:empty) {
  padding: 10px 12px;
  border-inline-start: 3px solid var(--bad);
  border-radius: 4px;
  color: var(--bad);
  background: var(--bad-soft);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}
.brand-mark .icon { width: 23px; height: 23px; }
.brand-name { font-size: 1.0625rem; font-weight: 750; line-height: 1.25; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: var(--bar-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-start, .topbar-account { display: flex; min-width: 0; align-items: center; gap: 12px; }
.public-topbar { flex-wrap: wrap; }
.public-topbar + .main { min-height: 70svh; }
.account-email { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 33ch; padding: 10px; border-radius: var(--control-radius); color: var(--ink); text-decoration: none; }
.account-email:hover { background: var(--subtle); }
.menu-toggle { display: none; }
.workspace { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100svh - var(--bar-height)); }
.sidebar {
  position: sticky;
  top: var(--bar-height);
  align-self: start;
  height: calc(100dvh - var(--bar-height));
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 12px;
  overflow-y: auto;
}
.nav-group + .nav-group { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.nav-title { padding: 0 10px 8px; color: var(--muted); font-size: .875rem; font-weight: 650; }
.nav-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1px; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  color: var(--ink);
  text-decoration: none;
}
.nav-list a:hover { background: var(--subtle); }
.nav-list a[aria-current] { background: var(--accent-soft); color: var(--accent-active); font-weight: 700; box-shadow: inset 3px 0 var(--accent); }
.main { width: 100%; max-width: 1360px; min-width: 0; padding: 30px clamp(16px, 3vw, 40px) 56px; margin-inline: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.page-head > div { min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head p { margin-top: 6px; }
.page-body { display: grid; gap: 32px; min-width: 0; }
.magpie-frame { display: block; width: 100%; height: max(460px, calc(100dvh - var(--bar-height) - 146px)); border: 1px solid var(--line); border-radius: var(--control-radius); background: var(--surface); }
.section { min-width: 0; display: grid; gap: 12px; align-content: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.section-head a { min-height: 44px; display: inline-flex; gap: 6px; align-items: center; }
.guide-steps { padding-inline-start: 1.5rem; }
.guide-steps li + li { margin-top: 8px; }
[data-model-results] { min-width: 0; }
#model-list > .field { max-width: 28rem; }
#guide-api details > * + * { margin-top: 8px; }
.trial-result { max-width: 760px; margin-top: 28px; }
.trial-result pre { font-family: inherit; font-size: 1rem; }
.trial-result a { width: fit-content; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--control-radius); padding: 18px 20px; min-width: 0; }
.stat:first-child { border-color: #b6caf2; background: var(--accent-soft); }
.stat dt { color: var(--muted); font-weight: 600; font-size: .9375rem; }
.stat dd { margin-top: 8px; font-size: 1.875rem; line-height: 1.3; font-weight: 730; font-variant-numeric: tabular-nums; }
.stat dd:has(.badge) { display: flex; align-items: center; min-height: 2.44rem; }
.stat small { font-size: .875rem; font-weight: 600; color: var(--muted); margin-inline-start: 6px; }
.connection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.connection-url { flex: 1 1 16rem; }
.connection-url input { border-color: transparent; background: var(--canvas); }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--control-radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9375rem; }
th, td { padding: 12px 14px; vertical-align: middle; }
thead th { background: var(--subtle); font-weight: 675; white-space: nowrap; }
tbody tr + tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--canvas); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date, .cell-action { white-space: nowrap; }
.cell-action { width: 1%; text-align: right; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  padding: 3px 8px;
  background: var(--subtle);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 625;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.empty, .state, .banner { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.state { display: grid; gap: 10px; justify-items: start; }
.banner { background: var(--accent-soft); border-color: #b6caf2; }
.banner-warn { background: var(--warn-soft); border-color: #d1ab68; }
.error { color: var(--bad); }
.error.state, .error.banner { background: var(--bad-soft); border-color: #e4a6b0; }
.form { display: grid; gap: 18px; width: 100%; max-width: 40rem; }
.form-wide { max-width: 54rem; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > :is(label, span):first-child { font-weight: 650; }
.field input, .field textarea, .field select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 11px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}
.field textarea { resize: vertical; }
.field input[readonly] { font-family: ui-monospace, Consolas, monospace; }
.field input[type="checkbox"] { width: 19px; height: 19px; min-height: 0; margin: 0; accent-color: var(--accent); }
.field-check { display: flex; align-items: center; gap: 10px; min-height: 44px; width: fit-content; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.group-picker { min-width: 0; max-height: 16rem; overflow: auto; border: 1px solid var(--line); border-radius: var(--control-radius); padding: 4px 12px 8px; }
.group-picker legend { padding-inline: 5px; font-weight: 650; }
.group-picker .field-check { width: 100%; }
.group-picker small { display: block; }
.group-picker code { overflow-wrap: anywhere; }
.form-feedback { color: var(--bad); overflow-wrap: anywhere; }
.form-feedback:empty { display: none; }
.details { display: grid; gap: 0; }
.details > div { display: grid; grid-template-columns: minmax(110px, .45fr) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); font-weight: 600; }
.notice {
  position: fixed;
  z-index: 4;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.notice:empty { padding: 0; }
dialog {
  width: min(570px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 16px 48px #14203135;
}
dialog::backdrop { background: #101a2b70; }
.dialog-inner { display: grid; gap: 16px; padding: 24px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-head h2 { overflow-wrap: anywhere; }
.dialog-status:empty { display: none; }

@media (max-width: 900px) {
  :root { --sidebar-width: 194px; }
  .sidebar { padding-inline: 10px; }
  th, td { padding-inline: 10px; }
}

@media (max-width: 710px) {
  :root { --bar-height: 64px; }
  .topbar { padding-inline: 10px; }
  .topbar-start { gap: 5px; }
  .topbar-account { gap: 4px; }
  .account-email, .topbar-account .badge { display: none; }
  .brand { gap: 7px; }
  .brand-name { font-size: .9375rem; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-mark .icon { width: 20px; height: 20px; }
  .menu-toggle { display: inline-flex; }
  .workspace { display: block; }
  .sidebar { display: none; position: sticky; z-index: 2; height: auto; max-height: 55dvh; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar.is-open { display: block; }
  .nav-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); }
  .main { padding-block: 22px 44px; }
  h1 { font-size: 1.75rem; }
  .page-head { padding-bottom: 16px; }
  .page-body { gap: 24px; }
}

@media (max-width: 420px) {
  .auth { padding-inline: 16px; }
  .auth-panel { padding: 20px; }
  .auth-heading h1 { font-size: 1.625rem; }
  .dialog-inner { padding: 16px; }
  .connection > button { width: 100%; }
  .field-grid { grid-template-columns: 1fr; }
  .topbar .brand-name { max-width: 13ch; }
}
