:root {
  color-scheme: light;
  --background: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --border: #d9dee7;
  --border-strong: #bac3d1;
  --text: #172033;
  --text-muted: #667085;
  --primary: #176b5b;
  --primary-hover: #0e5548;
  --primary-soft: #e6f3ef;
  --accent: #d97706;
  --danger: #b42318;
  --danger-soft: #feeceb;
  --success: #067647;
  --success-soft: #e7f6ed;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.07);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 56px);
  color: #ffffff;
  background: #172033;
  border-bottom: 3px solid var(--accent);
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #172033;
  font-weight: 800;
  background: #f3b64b;
  border-radius: 6px;
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.app-header p {
  margin: 3px 0 0;
  color: #b9c1cf;
  font-size: 12px;
}

.local-badge {
  margin-left: auto;
  padding: 5px 9px;
  color: #d6e6e1;
  font-size: 12px;
  border: 1px solid #3d665f;
  border-radius: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(1480px, 100%);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
}

.request-panel,
.response-panel,
.workflow-panel,
.workflow-result-panel {
  min-width: 0;
  padding: 24px clamp(18px, 2.4vw, 32px) 28px;
}

.workflow-panel,
.workflow-result-panel,
.history-panel {
  border-top: 1px solid var(--border);
}

.request-panel,
.progress-panel,
.content-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.response-panel,
.workflow-result-panel {
  background: var(--surface-muted);
}

.history-panel {
  grid-column: 1 / -1;
  background: var(--surface);
}

.request-panel,
.response-panel {
  grid-row: 1;
}

.request-panel,
.progress-panel,
.content-panel {
  grid-column: 1;
}

.response-panel,
.progress-result-panel,
.content-result-panel {
  grid-column: 2;
}

.progress-panel,
.progress-result-panel {
  grid-row: 2;
}

.content-panel,
.content-result-panel {
  grid-row: 3;
}

.history-panel {
  grid-row: 4;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 36px;
  margin-bottom: 16px;
}

.section-heading > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-index {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.button {
  min-height: 38px;
  padding: 0 14px;
  font-weight: 650;
  border-radius: 5px;
}

.button-primary {
  min-width: 108px;
  color: #ffffff;
  background: var(--primary);
  border: 1px solid var(--primary);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button-secondary {
  color: #344054;
  background: #ffffff;
  border: 1px solid var(--border-strong);
}

.button-secondary:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.request-line {
  display: grid;
  grid-template-columns: 106px minmax(160px, 1fr) 116px;
  gap: 8px;
}

.workflow-request-line {
  display: grid;
  grid-template-columns: 106px minmax(160px, 1fr) 116px;
  gap: 8px;
}

.workflow-request-line input,
.workflow-request-line select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
}

.workflow-request-line select {
  color: var(--primary);
  font-weight: 750;
}

.workflow-request-line input[readonly] {
  color: #475467;
  background: #f8fafc;
}

.workflow-state {
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
}

.workflow-result {
  margin-top: 0;
}

.workflow-result progress {
  display: block;
  width: 100%;
  height: 12px;
  margin: 4px 0 14px;
  accent-color: var(--primary);
}

.response-code.workflow-response-code {
  min-height: 112px;
  max-height: 260px;
}

.workflow-media {
  margin-top: 12px;
}

.result-section-heading {
  margin-bottom: 12px;
}

.workflow-result-empty {
  display: grid;
  min-height: 112px;
  place-items: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border-strong);
}

.workflow-result:not([hidden]) + .workflow-result-empty {
  display: none;
}

.history-empty {
  margin: 0;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  border: 1px dashed var(--border-strong);
}

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

.history-item {
  min-width: 0;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.history-item-header,
.history-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-stage {
  color: var(--primary);
  font-size: 13px;
  font-weight: 750;
}

.history-time,
.history-meta {
  color: var(--text-muted);
  font-size: 11px;
}

.history-url {
  margin: 10px 0;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.history-method {
  margin-right: 6px;
  color: var(--success);
  font-weight: 750;
}

.history-restore {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 650;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}

.history-restore:hover {
  border-color: var(--primary);
}

input,
select,
textarea {
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
}

.request-line input,
.request-line select,
.field-block input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
}

.request-line select {
  color: var(--primary);
  font-weight: 750;
}

.field-block {
  margin-top: 14px;
}

.field-block > label,
.auth-fields label {
  display: inline-block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.auth-fields {
  display: grid;
  grid-template-columns: minmax(190px, 0.42fr) minmax(240px, 1fr);
  gap: 12px;
}

.auth-method-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
}

.auth-hint {
  grid-column: 1 / -1;
  margin-top: -4px;
}

.curl-import > label {
  display: inline-block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.curl-input {
  min-height: 96px;
  font-size: 12px;
  background: #fbfcfd;
}

.curl-import-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.curl-import-footer .is-valid {
  color: var(--success);
}

.curl-import-footer .is-invalid {
  color: var(--danger);
}

.curl-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.button-compact {
  min-width: auto;
  min-height: 34px;
  padding-inline: 12px;
  font-size: 12px;
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 68px;
}

.icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
  height: 34px;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  background: transparent;
  border: 0;
}

.icon-button:hover {
  color: var(--primary);
}

.field-hint {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

code {
  color: #384250;
  font-family: Consolas, "Courier New", monospace;
}

.tabs {
  display: flex;
  gap: 24px;
  margin-top: 18px;
  border-bottom: 1px solid var(--border);
}

.tab,
.response-tab {
  position: relative;
  padding: 10px 1px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
  background: transparent;
  border: 0;
}

.tab.is-active,
.response-tab.is-active {
  color: var(--primary);
}

.tab.is-active::after,
.response-tab.is-active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  content: "";
  background: var(--primary);
}

.count {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  margin-left: 3px;
  place-items: center;
  color: var(--text-muted);
  font-size: 10px;
  background: #e9edf2;
  border-radius: 9px;
}

.tab-panel {
  padding-top: 16px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 200px;
  padding: 14px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.editor-footer .is-valid {
  color: var(--success);
}

.editor-footer .is-invalid {
  color: var(--danger);
}

.text-button,
.add-row-button {
  padding: 0;
  color: var(--primary);
  font-weight: 650;
  background: transparent;
  border: 0;
}

.key-value-list {
  display: grid;
  gap: 8px;
}

.key-value-row {
  display: grid;
  grid-template-columns: 22px minmax(100px, 0.8fr) minmax(120px, 1.2fr) 32px;
  align-items: center;
  gap: 8px;
}

.key-value-row input[type="text"] {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
}

.key-value-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.remove-row {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  font-size: 22px;
  background: transparent;
  border: 0;
}

.remove-row:hover {
  color: var(--danger);
}

.add-row-button {
  margin-top: 14px;
}

.form-error {
  margin: 16px 0 0;
  padding: 10px 12px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
}

.response-empty {
  display: grid;
  min-height: 300px;
  place-content: center;
  padding: 30px;
  text-align: center;
  border: 1px dashed var(--border-strong);
}

.empty-symbol {
  margin-bottom: 12px;
  color: var(--border-strong);
  font-family: Consolas, monospace;
  font-size: 54px;
}

.response-empty h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.response-empty p {
  max-width: 340px;
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.response-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 42px;
  color: var(--text-muted);
  font-size: 12px;
}

.status-badge {
  padding: 5px 8px;
  color: var(--success);
  font-weight: 750;
  background: var(--success-soft);
  border-radius: 4px;
}

.status-badge.is-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.response-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--border);
}

.response-code {
  min-height: 300px;
  max-height: calc(100vh - 220px);
  margin: 14px 0 0;
  padding: 16px;
  overflow: auto;
  color: #d6deeb;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #1d2533;
  border: 1px solid #303b4d;
  border-radius: 5px;
  box-shadow: var(--shadow);
}

.media-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.media-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.media-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-heading h3 {
  margin: 0;
  font-size: 15px;
}

.media-heading > span {
  color: var(--text-muted);
  font-size: 12px;
  text-align: right;
}

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

.media-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  background: #ffffff;
  border: 1px dashed var(--border-strong);
}

.media-item {
  min-width: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.media-item.is-video,
.media-item.is-unknown {
  grid-column: 1 / -1;
}

.media-preview {
  display: block;
  width: 100%;
  min-height: 180px;
  max-height: 480px;
  object-fit: contain;
  background: #111827;
}

video.media-preview {
  aspect-ratio: 16 / 9;
}

.media-item-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 11px;
}

.media-path {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-link {
  flex: 0 0 auto;
  color: var(--primary);
  font-weight: 650;
  text-decoration: none;
}

.media-link:hover {
  text-decoration: underline;
}

.media-load-error {
  display: grid;
  min-height: 130px;
  place-items: center;
  padding: 16px;
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  background: var(--danger-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

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

  .request-panel,
  .response-panel,
  .workflow-panel,
  .workflow-result-panel,
  .history-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .request-panel,
  .progress-panel,
  .content-panel {
    border-right: 0;
  }

  .request-panel {
    border-bottom: 1px solid var(--border);
  }

  .response-code {
    max-height: 560px;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding-inline: 16px;
  }

  .app-header p,
  .local-badge {
    display: none;
  }

  .request-panel,
  .response-panel,
  .workflow-panel,
  .workflow-result-panel {
    padding: 22px 16px 32px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .request-line {
    grid-template-columns: 94px minmax(0, 1fr);
  }

  .workflow-request-line {
    grid-template-columns: 94px minmax(0, 1fr);
  }

  .request-line .button-primary,
  .workflow-request-line .button-primary {
    grid-column: 1 / -1;
  }

  .workflow-state {
    text-align: left;
  }

  .auth-fields {
    grid-template-columns: 1fr;
  }

  .auth-hint {
    grid-column: 1;
  }

  .curl-import-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .media-content {
    grid-template-columns: 1fr;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .media-item,
  .media-item.is-video,
  .media-item.is-unknown {
    grid-column: 1;
  }

  .media-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .media-heading > span {
    text-align: left;
  }

  .tabs {
    gap: 14px;
    overflow-x: auto;
  }

  .tab {
    flex: 0 0 auto;
  }

  .key-value-row {
    grid-template-columns: 20px minmax(0, 1fr) 30px;
  }

  .key-value-row .row-value {
    grid-column: 2 / 3;
  }

  .key-value-row .remove-row {
    grid-column: 3;
    grid-row: 1 / 3;
  }
}
