:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687385;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b45309;
  --danger: #b91c1c;
  --code: #101827;
  --soft: #eef6f5;
  --soft-warn: #fff7ed;
  --soft-danger: #fef2f2;
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
  --field: #ffffff;
  --hover: #fbfcfd;
  --line-strong: #b8c0cc;
  --toast-bg: #17202a;
  --toast-ink: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* 作者样式会覆盖 UA 的 [hidden]，必须显式兜底（.card/.field 均设置了 display） */
[hidden] {
  display: none !important;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.nav-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  width: fit-content;
}

.nav-home:hover {
  color: var(--accent-strong);
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
  font-weight: 760;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(23, 32, 42, 0.04);
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.btn.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

.icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.grid-stack {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  min-height: 56px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
}

.panel-body {
  padding: 18px;
}

.panel-body.tight {
  padding: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.warn {
  background: var(--soft-warn);
  color: var(--warn);
}

.badge.danger {
  background: var(--soft-danger);
  color: var(--danger);
}

.rows {
  display: grid;
}

.row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

.key {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.value {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mono {
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.empty {
  color: var(--muted);
}

.warn {
  color: var(--warn);
}

.danger {
  color: var(--danger);
}

.raw {
  margin: 0;
  min-height: 420px;
  max-height: 680px;
  overflow: auto;
  padding: 18px;
  background: var(--code);
  color: #d9f7ef;
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 8px;
}

.field + .field {
  margin-top: 14px;
}

.field-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.5;
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.45;
}

.status.error {
  background: var(--soft-danger);
  color: var(--danger);
}

.status.warn {
  background: var(--soft-warn);
  color: var(--warn);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.seg button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 0 14px;
  cursor: pointer;
  color: var(--ink);
}

.seg button:last-child {
  border-right: 0;
}

.seg button.active {
  background: var(--soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.seg button:hover:not(.active) {
  background: var(--hover);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 168px;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 14px 34px rgba(23, 32, 42, 0.1);
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 14px;
}

.card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 740;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.card-meta {
  margin-top: auto;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.snapshot {
  margin-bottom: 20px;
}

.snapshot .row {
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: start;
}

.snapshot .value {
  padding-right: 8px;
}

.snapshot .btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  box-shadow: none;
}

.section-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.footer-note {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
}

.tool-search {
  margin-bottom: 16px;
}

.tool-search input {
  padding-left: 14px;
}

.search-empty {
  display: none;
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.search-empty.show {
  display: block;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.tool-capability-notice,
.tool-error-boundary {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  border-radius: 8px;
  background: var(--soft-warn);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.tool-error-boundary {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: var(--soft-danger);
  color: var(--danger);
}

@media (max-width: 900px) {
  .grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .snapshot .row {
    grid-template-columns: 1fr;
  }

  .snapshot .btn {
    width: fit-content;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121619;
    --panel: #1b2125;
    --ink: #edf2f4;
    --muted: #a7b1b8;
    --line: #39434a;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --warn: #fbbf24;
    --danger: #f87171;
    --code: #0b0f12;
    --soft: #173b37;
    --soft-warn: #3a2b16;
    --soft-danger: #3c2023;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    --field: #12171a;
    --hover: #242c31;
    --line-strong: #56636c;
    --toast-bg: #edf2f4;
    --toast-ink: #12171a;
  }

  .btn {
    background: var(--panel);
    color: var(--ink);
  }

  .btn.primary {
    color: #062a26;
  }

  .card:hover {
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  }
}
