/* The inspector keeps its bespoke component CSS but sources every color/radius
   from `@antfu/design`'s palette — the local token names below mirror the design
   system's `bg-base` / `bg-secondary` / `color-*` / `border-base` semantics and
   flip via the `.dark` class. Only the domain-specific JSON/RPC syntax palette is
   defined per theme here. */
:root {
  --df-radius: 0.5rem;
  --df-bg: #fff;
  --df-bg-soft: #f5f5f5;
  --df-bg-active: rgba(136, 136, 136, 0.067);
  --df-border: rgba(136, 136, 136, 0.13);
  --df-border-soft: rgba(136, 136, 136, 0.067);
  --df-fg: #262626;
  --df-fg-dim: #525252;
  --df-fg-faint: #737373;
  --df-accent: #3a6a45;
  --df-accent-dim: color-mix(in srgb, #3a6a45 22%, transparent);
  --df-danger: #e11d48;
  --df-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --df-sans: var(--font-sans, "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);

  /* JSON / RPC syntax palette — light */
  --df-query: #2563c9;
  --df-static: #8a45c9;
  --df-action: #b9701f;
  --df-event: #c43d75;
  --df-string: #1f8a52;
  --df-number: #9a6315;
  --df-boolean: #7a32bf;
  --df-null: #93a0ad;
  --df-key: #2a5fa6;
}

.dark {
  --df-bg: #111;
  --df-bg-soft: #1a1a1a;
  --df-fg: #e5e5e5;
  --df-fg-dim: #a3a3a3;
  --df-fg-faint: #737373;
  --df-accent: #6fb07d;
  --df-accent-dim: color-mix(in srgb, #6fb07d 22%, transparent);
  --df-danger: #fb7185;

  /* JSON / RPC syntax palette — dark */
  --df-query: #6ea8fe;
  --df-static: #c792ea;
  --df-action: #ffb08f;
  --df-event: #e06b9b;
  --df-string: #95d6a4;
  --df-number: #e6b673;
  --df-boolean: #d39bf0;
  --df-null: #76828f;
  --df-key: #7fb0e8;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  background: var(--df-bg);
  color: var(--df-fg);
  font-family: var(--df-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

code,
.mono {
  font-family: var(--df-mono);
}

input,
textarea {
  font-family: inherit;
  color: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ---- header: the LayoutToolbar, LayoutTabs and ActionIconButton come from
   `@antfu/design`; the connection indicator comes from `design/design.ts`. ---- */

/* ---- body ---- */
.app-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.center {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--df-fg-dim);
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  text-align: center;
}

.pane {
  height: 100%;
  overflow: auto;
}

/* ---- toolbar / search ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  background: var(--df-bg);
  border-bottom: 1px solid var(--df-border-soft);
  z-index: 2;
}

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius);
  padding: 5px 10px;
  background: transparent;
}

.search:focus-within {
  border-color: var(--df-accent);
}

.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12.5px;
}

.search svg {
  color: var(--df-fg-faint);
  flex-shrink: 0;
}

.muted {
  color: var(--df-fg-dim);
  font-size: 11.5px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--df-fg-dim);
  cursor: pointer;
  user-select: none;
}

/* ---- badges ---- */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--df-mono);
  background: var(--df-bg-active);
  color: var(--df-fg-dim);
  border: 1px solid var(--df-border);
  letter-spacing: 0.02em;
}

.badge.query {
  color: var(--df-query);
}

.badge.static {
  color: var(--df-static);
}

.badge.action {
  color: var(--df-action);
}

.badge.event {
  color: var(--df-event);
}

.badge.flag {
  background: transparent;
  color: var(--df-fg-faint);
  font-weight: 500;
}

.badge.agent {
  color: var(--df-accent);
  border-color: var(--df-accent-dim);
}

.badge.safety-destructive {
  color: var(--df-danger);
}

/* ---- function list ---- */
.fn-list {
  padding: 8px 14px 14px;
}

.fn-row {
  border-top: 1px solid var(--df-border-soft);
}

.fn-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  cursor: default;
}

.fn-head.clickable {
  cursor: pointer;
}

.fn-head.clickable:hover {
  background: var(--df-bg-soft);
}

.fn-name {
  font-family: var(--df-mono);
  font-size: 12.5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Colored namespace segments of a function name (split on `:` / `/`).
   Namespace segments receive an inline hash color; the trailing leaf falls
   back to the default foreground, and separators stay faint. */
.fn-name .ns-seg {
  color: var(--df-fg);
}

.fn-name .ns-sep {
  color: var(--df-fg-faint);
}

.fn-flags {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.chev {
  color: var(--df-fg-faint);
  width: 14px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.chev.open {
  transform: rotate(90deg);
}

.fn-detail {
  padding: 4px 12px 14px 30px;
  background: var(--df-bg-soft);
  border-top: 1px solid var(--df-border-soft);
}

.fn-detail .desc {
  color: var(--df-fg-dim);
  margin: 8px 0;
  font-size: 12px;
}

.label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--df-fg-faint);
  margin: 12px 0 5px;
  font-weight: 600;
}

textarea.args {
  width: 100%;
  min-height: 58px;
  resize: vertical;
  background: var(--df-bg);
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius);
  padding: 8px 10px;
  font-family: var(--df-mono);
  font-size: 12px;
  outline: none;
}

textarea.args:focus {
  border-color: var(--df-accent);
}

.result {
  margin-top: 10px;
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius);
  padding: 10px 12px;
  background: var(--df-bg);
}

.result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
}

.result-head .ok {
  color: var(--df-accent);
  font-weight: 600;
}

.result-head .fail {
  color: var(--df-danger);
  font-weight: 600;
}

.note {
  color: var(--df-fg-faint);
  font-size: 11.5px;
  font-style: italic;
}

/* ---- commands list ---- */
.cmd-icon {
  flex-shrink: 0;
  color: var(--df-fg-dim);
}

.cmd-title {
  font-size: 12.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.cmd-id {
  font-size: 11px;
  color: var(--df-fg-faint);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-row-child .fn-head {
  padding-left: 22px;
}

.cmd-children {
  padding-left: 16px;
  border-left: 1px solid var(--df-border-soft);
  margin-left: 5px;
}

.cmd-children .fn-row {
  border-top: none;
  border-bottom: 1px solid var(--df-border-soft);
}

.cmd-children .fn-row:last-child {
  border-bottom: none;
}

/* ---- state view ---- */
.split {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.keys {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--df-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--df-bg-soft);
}

.keys-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--df-border-soft);
  font-size: 11px;
  color: var(--df-fg-dim);
}

.keys-list {
  flex: 1;
  overflow: auto;
}

.key-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--df-fg-dim);
  padding: 8px 12px;
  font-family: var(--df-mono);
  font-size: 11.5px;
  border-bottom: 1px solid var(--df-border-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.1s;
}

.key-item:hover {
  background: var(--df-bg-active);
}

.key-item.active {
  background: var(--df-bg-active);
  color: var(--df-accent);
  box-shadow: inset 2px 0 0 var(--df-accent);
}

.state-main {
  flex: 1;
  overflow: auto;
  padding: 14px 16px;
  min-width: 0;
}

.state-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.state-key {
  font-family: var(--df-mono);
  font-size: 13px;
  color: var(--df-accent);
}

.pulse {
  color: var(--df-accent);
  font-size: 11px;
}

/* ---- json tree ---- */
.json {
  font-family: var(--df-mono);
  font-size: 12px;
  line-height: 1.6;
}

.json-row {
  display: flex;
  align-items: flex-start;
  border-radius: 4px;
  padding: 0 3px;
}

.json-toggle {
  cursor: pointer;
  user-select: none;
}

.json-toggle:hover {
  background: var(--df-bg-active);
}

.json-caret {
  display: inline-block;
  width: 12px;
  color: var(--df-fg-faint);
  flex-shrink: 0;
  transition: transform 0.12s;
}

.json-caret.open {
  transform: rotate(90deg);
}

.json-key {
  color: var(--df-key);
}

.json-colon {
  color: var(--df-fg-faint);
  margin: 0 5px 0 1px;
}

.json-children {
  padding-left: 16px;
  border-left: 1px solid var(--df-border-soft);
  margin-left: 5px;
}

.json-meta {
  color: var(--df-fg-faint);
  font-size: 11px;
}

.v-string {
  color: var(--df-string);
}

.v-number {
  color: var(--df-number);
}

.v-boolean {
  color: var(--df-boolean);
}

.v-null {
  color: var(--df-null);
  font-style: italic;
}

.json-row.changed {
  background: var(--df-accent-dim);
  animation: fade-change 1.6s ease-out forwards;
}

@keyframes fade-change {
  0% {
    background: var(--df-accent-dim);
  }
  100% {
    background: transparent;
  }
}

/* ---- agent view ---- */
.cards {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius);
  background: var(--df-bg-soft);
  padding: 12px 13px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.card-title {
  font-weight: 600;
  font-size: 13px;
}

.card .id {
  font-family: var(--df-mono);
  font-size: 11px;
  color: var(--df-fg-faint);
  word-break: break-all;
}

/* Shown only when the sanitized MCP wire name (`.id`, above) differs from
   the tool's internal registration id — see `toAgentToolName`. */
.card .id-note {
  font-family: var(--df-mono);
  font-size: 10px;
  color: var(--df-fg-faint);
  opacity: 0.7;
  word-break: break-all;
  margin-top: 1px;
}

.card .desc {
  color: var(--df-fg-dim);
  font-size: 12px;
  margin: 7px 0;
}

.tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--df-fg-faint);
  font-weight: 600;
  padding: 14px 14px 0;
}

.empty {
  color: var(--df-fg-faint);
  padding: 14px;
  font-style: italic;
}

/* ---- instances view ---- */
.inst-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-top: 8px;
  font-family: var(--df-mono);
  font-size: 12px;
  color: var(--df-accent);
  text-decoration: none;
}

.inst-url:hover {
  text-decoration: underline;
}

.inst-url-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inst-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0 0;
}

.inst-meta > div {
  min-width: 0;
}

.inst-meta-wide {
  grid-column: 1 / -1;
}

.inst-meta dt {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--df-fg-faint);
  font-weight: 600;
}

.inst-meta dd {
  margin: 2px 0 0;
  font-family: var(--df-mono);
  font-size: 12px;
  color: var(--df-fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inst-empty {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
  color: var(--df-fg-dim);
}

.inst-empty p {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
}

.inst-empty-icon {
  font-size: 32px;
  color: var(--df-fg-faint);
}

.inst-empty-title {
  margin-top: 10px !important;
  font-size: 14px;
  font-weight: 600;
  color: var(--df-fg);
}

.inst-empty code,
.toolbar code {
  font-family: var(--df-mono);
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--df-bg-active);
  color: var(--df-fg-dim);
}
