:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --surface-strong: #eef2f4;
  --line: #d8e0e4;
  --line-soft: #e8edf0;
  --text: #172026;
  --muted: #63717a;
  --muted-2: #8b98a0;
  --cyan: #0ea5b7;
  --green: #4f8f2f;
  --green-soft: #e8f5df;
  --amber: #b7791f;
  --amber-soft: #fff4d6;
  --red: #d1435b;
  --red-soft: #ffe8ec;
  --blue: #2563eb;
  --blue-soft: #e7efff;
  --shadow: 0 18px 60px rgba(23, 32, 38, 0.1);
  --radius: 8px;
  --mono: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Consolas", monospace;
  --sans: "IBM Plex Sans", "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  letter-spacing: 0;
  background:
    linear-gradient(rgba(23, 32, 38, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 38, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 12% 0%, rgba(14, 165, 183, 0.13), transparent 34%),
    radial-gradient(circle at 84% -6%, rgba(79, 143, 47, 0.11), transparent 30%),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  height: calc(100vh - 32px);
  margin: 16px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 5px;
  border: 1px solid #cbd5da;
  border-radius: 8px;
  background: #f7fafb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.mark span {
  border-radius: 3px;
  background: #a3d977;
}

.mark span:nth-child(2) {
  background: #7dd3fc;
}

.mark span:nth-child(3) {
  background: #f2c14e;
}

.mark span:nth-child(4) {
  background: #172026;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 700;
}

.runtime-pill {
  min-width: 112px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f9fbfc;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted-2);
}

.runtime-pill[data-state="running"] {
  color: var(--cyan);
  border-color: rgba(14, 165, 183, 0.38);
  background: #ebfbfd;
}

.runtime-pill[data-state="running"] .pulse-dot {
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(14, 165, 183, 0.32);
  animation: pulse 1.2s infinite;
}

.runtime-pill[data-state="success"] {
  color: var(--green);
  border-color: rgba(79, 143, 47, 0.34);
  background: var(--green-soft);
}

.runtime-pill[data-state="success"] .pulse-dot {
  background: var(--green);
}

.runtime-pill[data-state="error"] {
  color: var(--red);
  border-color: rgba(209, 67, 91, 0.35);
  background: var(--red-soft);
}

.runtime-pill[data-state="error"] .pulse-dot {
  background: var(--red);
}

@keyframes pulse {
  100% {
    box-shadow: 0 0 0 10px rgba(14, 165, 183, 0);
  }
}

.workspace {
  height: calc(100vh - 109px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
}

.control-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1px;
  border-right: 1px solid var(--line);
  background: var(--line);
  overflow: auto;
}

.execution-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) minmax(220px, 0.58fr);
  background: var(--line);
  gap: 1px;
}

.panel,
.command-strip {
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, 0.96);
}

.panel {
  padding: 18px;
}

.panel-heading {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-heading.compact {
  margin-bottom: 0;
}

.panel-heading .section-index {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
}

.config-form {
  margin: 0;
}

.requirement-card {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcfd;
}

.requirement-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 720;
}

.requirement-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.requirement-card code {
  font-family: var(--mono);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fbfcfd;
  padding: 0 12px;
}

.field input:focus,
.field select:focus {
  border-color: rgba(14, 165, 183, 0.68);
  box-shadow: 0 0 0 3px rgba(14, 165, 183, 0.12);
}

.upload-zone {
  position: relative;
  min-height: 108px;
  display: grid;
  place-items: stretch;
  border: 1px dashed #b8c5cb;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(14, 165, 183, 0.08), transparent 42%),
    #fbfcfd;
  overflow: hidden;
}

.upload-zone.is-dragging {
  border-color: var(--cyan);
  background:
    linear-gradient(135deg, rgba(14, 165, 183, 0.14), transparent 48%),
    #f1fbfd;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-face {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.upload-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #cbd5da;
  border-radius: 8px;
  color: var(--cyan);
  background: #ffffff;
  font-family: var(--mono);
  font-size: 23px;
}

.upload-face strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.upload-face small {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
}

.sample-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.ghost-button,
.tool-button,
.copy-button,
.primary-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.ghost-button,
.tool-button,
.copy-button {
  color: var(--muted);
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.ghost-button:hover,
.tool-button:hover,
.copy-button:hover {
  color: var(--text);
  border-color: #b5c2c8;
  background: #f4f8fa;
}

.primary-button {
  color: #ffffff;
  background: var(--text);
  border: 1px solid var(--text);
  font-weight: 760;
  box-shadow: 0 8px 18px rgba(23, 32, 38, 0.12);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #26333a;
}

.primary-button:disabled,
.tool-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.data-summary {
  min-height: 172px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 26px 16px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line-soft);
}

.metric {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line-soft);
  background: #ffffff;
}

.metric:nth-child(2n) {
  border-right: 0;
}

.metric span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.preview-code {
  max-height: 190px;
  margin: 0;
  padding: 13px;
  overflow: auto;
  color: #2c3a42;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.command-strip {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

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

.action-group .primary-button,
.action-group .tool-button {
  padding: 0 16px;
}

.log-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.log-counter {
  margin-left: auto;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
}

.timeline {
  min-height: 0;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(23, 32, 38, 0.035) 1px, transparent 1px),
    #fbfcfd;
  background-size: 56px 56px;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.74);
}

.timeline-entry:last-child {
  border-bottom: 0;
}

.timeline-meta {
  min-width: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line-soft);
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 11px;
}

.timeline-meta time,
.timeline-meta span {
  display: block;
}

.timeline-meta span {
  margin-top: 8px;
  text-transform: uppercase;
}

.timeline-body {
  min-width: 0;
  padding: 14px 16px 15px;
}

.timeline-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 720;
}

.timeline-title::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--muted-2);
}

.timeline-entry[data-type="input"] {
  background: var(--amber-soft);
}

.timeline-entry[data-type="tool"] {
  background: var(--blue-soft);
}

.timeline-entry[data-type="result"] {
  background: var(--green-soft);
}

.timeline-entry[data-type="error"] {
  background: var(--red-soft);
}

.timeline-entry[data-type="input"] .timeline-title::before {
  background: var(--amber);
}

.timeline-entry[data-type="thought"] .timeline-title::before {
  background: var(--muted);
}

.timeline-entry[data-type="tool"] .timeline-title::before {
  background: var(--blue);
}

.timeline-entry[data-type="result"] .timeline-title::before {
  background: var(--green);
}

.timeline-entry[data-type="error"] .timeline-title::before {
  background: var(--red);
}

.timeline-entry[data-type="input"] .timeline-title {
  color: var(--amber);
}

.timeline-entry[data-type="tool"] .timeline-title {
  color: var(--blue);
}

.timeline-entry[data-type="result"] .timeline-title {
  color: var(--green);
}

.timeline-entry[data-type="error"] .timeline-title {
  color: var(--red);
}

.timeline-text {
  color: #34424a;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.payload {
  margin-top: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  overflow: hidden;
}

.payload-label {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.payload pre {
  max-height: 180px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  color: #25323a;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.copy-button {
  margin-left: auto;
  min-height: 32px;
  padding: 0 12px;
}

.result-output {
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: #172026;
  background: #fbfcfd;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 13px;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1060px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-rail {
    border-right: 0;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .execution-stage {
    min-height: 760px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .topbar,
  .command-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .runtime-pill {
    width: 100%;
  }

  .control-rail {
    grid-template-columns: 1fr;
  }

  .timeline-entry {
    grid-template-columns: 1fr;
  }

  .timeline-meta {
    display: flex;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .timeline-meta span {
    margin-top: 0;
  }

  .action-group {
    display: grid;
    grid-template-columns: 1fr;
  }
}
