:root {
  --bg: #080b0f;
  --panel: #0f151c;
  --panel-2: #131b24;
  --line: #22303d;
  --line-soft: #1a2530;
  --text: #e6edf3;
  --muted: #8b9bab;
  --accent: #b8f24a;
  --accent-2: #4ad6f2;
  --danger: #ff6b6b;
  --warn: #f5c451;
  --ok: #6ee7a8;
  --radius: 14px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(184, 242, 74, .09), transparent 60%),
    radial-gradient(700px 400px at 90% 0%, rgba(74, 214, 242, .07), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 24px;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono, code, pre { font-family: var(--mono); }
.muted { color: var(--muted); }
.wrap { max-width: 1320px; margin: 0 auto; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  justify-content: space-between; margin-bottom: 22px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 19px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
.brand .ver {
  color: var(--muted); font-size: 12px; border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 9px;
}
.nav { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 3px; }
.nav a {
  color: var(--muted); font-size: 13px; padding: 5px 14px; border-radius: 99px;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(184, 242, 74, .12); color: var(--accent); }
.token-box { display: flex; gap: 8px; align-items: center; }
.token-box input { width: 220px; }
#status.ok { color: var(--ok); }
#status.bad { color: var(--danger); }

input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  outline: none; transition: border-color .15s, background .15s, opacity .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); }
input::placeholder, textarea::placeholder { color: #5b6b7a; }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
button { cursor: pointer; background: #18222d; width: auto; }
button:hover { border-color: #3a4d5f; background: #1b2733; }
button.primary { background: var(--accent); border-color: var(--accent); color: #0a1005; font-weight: 650; }
button.primary:hover { filter: brightness(1.05); }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 60%), var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: .01em; }
.panel-head .sub { color: var(--muted); font-size: 12px; }

.field-block { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-block > span { font-size: 12px; color: var(--muted); }
.field-block .counter { align-self: flex-end; font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; color: #b9c7d4; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px; cursor: pointer;
  width: auto;
}
.chip:hover { border-color: #3a4d5f; }
.chip.active { border-color: rgba(184,242,74,.6); color: var(--accent); background: rgba(184,242,74,.08); }

.ref-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 8px; }
.ref-row .idx { display: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(110,231,168,.4); background: rgba(110,231,168,.07); }
.badge.fail { color: var(--danger); border-color: rgba(255,107,107,.4); background: rgba(255,107,107,.07); }
.badge.run { color: var(--warn); border-color: rgba(245,196,81,.4); background: rgba(245,196,81,.07); }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kv .item { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 9px; padding: 8px 10px; }
.kv .k { font-size: 11.5px; color: var(--muted); }
.kv .v { font-size: 13px; margin-top: 1px; word-break: break-all; }
.kv .v.cost { color: var(--accent); font-weight: 600; }

pre {
  margin: 0; background: #0a1016; border: 1px solid var(--line-soft); border-radius: 9px;
  padding: 12px; font-size: 12px; line-height: 1.5; overflow: auto; max-height: 420px;
  white-space: pre-wrap; word-break: break-word;
}
details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: #1b2733; border: 1px solid #3a4d5f; color: var(--text);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: .2s; font-size: 13px; max-width: 72vw; z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--danger); }

.spinner {
  width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--accent); border-radius: 50%; display: inline-block;
  animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); font-size: 12.5px; padding: 14px 2px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
td .prompt-cell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 960px) {
  body { padding: 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .token-box { width: 100%; }
  .token-box input { width: 100%; flex: 1; }
  .nav { order: 3; width: 100%; justify-content: center; }
}
