:root {
  --bg: #0f1115;
  --bg-soft: #151922;
  --card: #171b24;
  --card-2: #1d2230;
  --border: #272e3d;
  --text: #e8ecf4;
  --muted: #8b95a7;
  --accent: #2aabee;
  --accent-2: #1e8fca;
  --ok: #2ecc71;
  --bad: #ff5c6c;
  --warn: #f5b942;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.15rem;
}

h2 {
  font-size: 1.05rem;
}

p {
  margin: 0.6rem 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  padding: 0.08em 0.35em;
}

[hidden] {
  display: none !important;
}

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

.small {
  font-size: 0.82rem;
}

.error {
  color: var(--bad);
}

.pad {
  padding: 0.5rem 0.75rem;
}

/* topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.1rem;
  background: rgba(15, 17, 21, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #7b61ff);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0.1rem 0 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.user b {
  font-weight: 600;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok {
  color: #0b1a10;
  background: var(--ok);
  border-color: transparent;
}

.badge.bad {
  color: #2a0509;
  background: var(--bad);
  border-color: transparent;
}

/* banner */

.banner {
  margin: 0.8rem 1.1rem 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(245, 185, 66, 0.35);
  background: rgba(245, 185, 66, 0.08);
  color: #f6d491;
  border-radius: var(--radius);
  font-size: 0.86rem;
}

/* layout */

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.1rem 2rem;
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: calc(100vh - 96px);
  min-height: 0;
}

.search input,
.field input,
.field textarea,
.gate textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 0.62rem 0.75rem;
  font: inherit;
  outline: none;
}

.search input:focus,
.field input:focus,
.field textarea:focus,
.gate textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.16);
}

.method-list {
  overflow-y: auto;
  min-height: 0;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.method-list::-webkit-scrollbar {
  width: 8px;
}

.method-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

.section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.55rem 0.65rem 0.35rem;
  background: var(--card);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.method-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.method-item:hover {
  background: var(--bg-soft);
}

.method-item.active {
  background: rgba(42, 171, 238, 0.14);
  border-color: rgba(42, 171, 238, 0.4);
}

.m-name {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
}

.m-desc {
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* content */

.content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  min-width: 0;
}

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

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 0.85rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: #3a4356;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #061620;
}

.btn.primary:hover {
  background: #43b8f4;
}

.btn.ghost {
  background: transparent;
}

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

/* detail */

.detail h2 {
  font-family: var(--mono);
  font-size: 1.15rem;
}

.note {
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  font-size: 0.85rem;
}

.note.bad {
  background: rgba(255, 92, 108, 0.1);
  border: 1px solid rgba(255, 92, 108, 0.35);
  color: #ff9aa5;
}

.note.warn {
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.3);
  color: #f6d491;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.6rem;
}

table.params {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

table.params th,
table.params td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.params th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

table.params td.type {
  color: #b8c4da;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

table.params td.req {
  color: var(--warn);
  font-weight: 700;
}

/* execute */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}

.field > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.field textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
  min-height: 120px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(245, 185, 66, 0.35);
  background: rgba(245, 185, 66, 0.07);
  border-radius: 9px;
  color: #f6d491;
  font-size: 0.85rem;
}

.check input {
  margin-top: 0.2rem;
  accent-color: var(--warn);
}

/* response */

.code {
  margin: 0.4rem 0 0;
  padding: 0.85rem;
  max-height: 52vh;
  overflow: auto;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* gate */

.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.2rem;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(42, 171, 238, 0.12), transparent 60%),
    radial-gradient(700px 400px at 90% 100%, rgba(123, 97, 255, 0.1), transparent 60%),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 18px;
  padding: 1.3rem 1.4rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.gate-card .brand {
  margin-bottom: 0.8rem;
}

.gate details {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.gate summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.86rem;
}

.gate textarea {
  margin: 0.6rem 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  resize: vertical;
}

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(10px);
  z-index: 100;
  max-width: min(90vw, 520px);
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 0.86rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.ok {
  border-color: rgba(46, 204, 113, 0.5);
}

.toast.error {
  border-color: rgba(255, 92, 108, 0.5);
}

/* responsive */

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0.8rem;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .method-list {
    max-height: 34vh;
  }

  .topbar {
    padding: 0.65rem 0.8rem;
  }

  .user b {
    max-width: 40vw;
  }
}
