:root {
  color-scheme: light;
  --bg: #edf3ff;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.76);
  --surface-2: #f2f3f5;
  --surface-3: #f7f8fa;
  --line: #e3e8f2;
  --line-strong: #cfd8ec;
  --text: #0b0c0f;
  --muted: #4e5869;
  --muted-2: #86909c;
  --brand: #5d89f7;
  --brand-dark: #3570ff;
  --brand-soft: #e8f2ff;
  --brand-tint: #f1f6ff;
  --accent: #8768ff;
  --accent-soft: #f0ecff;
  --ok: #3eaf7c;
  --warn: #e6a23c;
  --danger: #f56c6c;
  --code-bg: #f7f8fa;
  --code-line: #e1e6f0;
  --code-text: #242e3a;
  --shadow: 0 8px 26px rgba(93, 137, 247, 0.12);
  font-family:
    "Source Han Sans", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 8px;
}

body {
  margin: 0;
  min-width: 1120px;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 8%, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0) 28rem),
    radial-gradient(circle at 75% 0%, rgba(211, 223, 255, 0.88), rgba(211, 223, 255, 0) 34rem),
    linear-gradient(156deg, #eef5ff 0%, #dfe9ff 50%, #c7d8ff 100%),
    var(--bg);
  background-attachment: fixed;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, #4678ff 0%, #b890ff 100%);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(93, 137, 247, 0.26);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

code {
  border-radius: 6px;
  background: var(--brand-soft);
  padding: 2px 6px;
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 28px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 34px;
  line-height: 1.16;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.subtitle {
  max-width: 900px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status-strip div {
  min-width: 0;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
}

.status-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
}

.status-strip strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 248px minmax(760px, 1fr);
  gap: 20px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.content .panel {
  padding: 22px;
}

.compact {
  padding: 14px;
}

.sticky {
  position: sticky;
  top: 18px;
}

.section-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-head.small {
  margin-bottom: 12px;
}

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

.primary,
.ghost,
.section-head button,
.event-simulator button {
  min-height: 40px;
  padding: 0 14px;
}

.segment-control {
  display: inline-flex;
  gap: 3px;
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.segment-control button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.segment-control button:hover {
  background: #fff;
  color: var(--brand-dark);
  transform: none;
  box-shadow: none;
}

.segment-control button.active,
.segment-control button[aria-pressed='true'] {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 4px 12px rgba(93, 137, 247, 0.14);
}

.ghost {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--brand-dark);
}

.ghost:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 8px 18px rgba(93, 137, 247, 0.14);
}

.danger {
  border-color: #ffd7d7;
  color: var(--danger);
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  min-width: 0;
}

.step-list button {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
  box-shadow: none;
}

.step-list button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.step-list span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.step-list b {
  min-width: 0;
}

.step-list li.active button {
  border-color: var(--brand);
  background: linear-gradient(90deg, #f0f5ff 0%, #e8f2ff 100%);
  color: var(--text);
}

.step-list li.done button {
  color: var(--text);
}

.step-list li.done span,
.step-list li.active span {
  background: var(--brand);
  color: #fff;
}

.hint,
.body-text,
.runbook p {
  color: var(--muted);
  line-height: 1.65;
}

.hint {
  margin: 12px 0 0;
  font-size: 13px;
}

.body-text {
  max-width: 980px;
  margin-bottom: 18px;
  font-size: 15px;
}

.step-panel {
  scroll-margin-top: 18px;
}

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

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

label {
  display: grid;
  grid-template-rows: 18px 42px;
  gap: 8px;
  min-width: 0;
}

label span {
  color: #242e3a;
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

input[readonly] {
  border-color: var(--line);
  background: #eef1f6;
  color: var(--muted);
  cursor: not-allowed;
}

textarea {
  min-height: 104px;
  padding: 12px;
  line-height: 1.55;
  resize: vertical;
}

.agent-message-grid {
  align-items: start;
  margin-bottom: 18px;
}

.agent-message-grid label {
  grid-template-rows: 18px minmax(112px, auto);
}

.agent-message-grid textarea {
  min-height: 118px;
  max-height: 180px;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(93, 137, 247, 0.16);
}

.notice {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #dce6ff;
  border-radius: 12px;
  background: linear-gradient(90deg, #f6f9ff 0%, #fff 100%);
  color: var(--muted);
  line-height: 1.6;
}

.notice strong {
  margin-right: 8px;
}

.config-tips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.config-tips div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-3);
}

.config-tips strong {
  display: block;
  margin-bottom: 6px;
  color: #242e3a;
  font-size: 12px;
}

.config-tips span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.api-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(360px, 1.18fr);
  gap: 16px;
}

.agent-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 0;
  clear: both;
}

.agent-preview-grid .code-block {
  min-height: 0;
}

.agent-preview-grid pre {
  min-height: 220px;
  max-height: 360px;
}

.api-grid > .code-block:first-child:nth-last-child(2),
.api-grid > .code-block:first-child:nth-last-child(2) + .code-block {
  min-width: 0;
}

.api-meta {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-3);
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
}

dt {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 800;
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #242e3a;
  font-size: 13px;
  line-height: 1.5;
}

.code-block {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--code-line);
  border-radius: 12px;
  background: var(--code-bg);
}

.code-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--code-line);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.code-title button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #cddafe;
  background: #fff;
  color: var(--brand-dark);
  font-size: 12px;
}

pre {
  min-height: 124px;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  color: var(--code-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}

pre::selection {
  background: rgba(93, 137, 247, 0.22);
}

.event-simulator {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.ws-connection-preview {
  margin-bottom: 18px;
}

.ws-connection-preview pre {
  min-height: 112px;
}

.event-simulator button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--brand-dark);
}

.runbook {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.runbook div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-3);
}

.runbook p {
  margin-bottom: 0;
  font-size: 13px;
}

.response pre {
  min-height: 132px;
  max-height: 260px;
}

.response[hidden] {
  display: none;
}

.step-runtime {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 248, 250, 0.82);
}

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

.runtime-head h3 {
  margin: 0;
  font-size: 15px;
}

.runtime-head button {
  min-height: 32px;
  padding: 0 12px;
}

.runtime-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 0.8fr);
  gap: 12px;
  padding: 12px;
}

.runtime-grid:has(.response[hidden]) {
  grid-template-columns: 1fr;
}

.step-log {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 260px;
  overflow: auto;
}

.log-empty {
  display: block;
  min-height: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 13px;
}

.log-entry {
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  background: #fff;
  font-size: 12px;
  line-height: 1.45;
}

.log-entry strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.log-entry span {
  color: var(--muted);
}

.log-entry.error {
  border-left-color: var(--danger);
}

.log-entry.warn {
  border-left-color: var(--warn);
}

.log-entry.ok {
  border-left-color: var(--ok);
}

@media (max-width: 1100px) {
  body {
    min-width: 0;
  }

  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: initial;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .runbook {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 28px, 720px);
    padding-top: 18px;
  }

  h1 {
    font-size: 28px;
  }

  .status-strip,
  .form-grid,
  .form-grid.three,
  .api-grid,
  .runtime-grid,
  .config-tips,
  .runbook {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button,
  .section-head > button {
    width: 100%;
  }

  .segment-control {
    width: 100%;
  }

  .segment-control button {
    width: 50%;
  }
}
