:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --blue: #0a84ff;
  --purple: #5e5ce6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ---------- 登录页 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(
      1200px 600px at 50% -10%,
      rgba(0, 113, 227, 0.12),
      transparent 60%
    ),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.35);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-card p {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ---------- 表单控件 ---------- */

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 8px;
  text-align: left;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

textarea {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.18s ease, opacity 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(255, 59, 48, 0.4);
}
.btn-danger:hover {
  background: rgba(255, 59, 48, 0.08);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: dark) {
  .topbar {
    background: rgba(28, 28, 30, 0.7);
  }
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.topbar .brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.topbar .right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.2);
}

/* ---------- 布局 ---------- */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 22px 60px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 18px;
}

.section-gap > * + * {
  margin-top: 16px;
}

/* ---------- 脚本输入 ---------- */

.script-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.script-row textarea {
  flex: 1;
  min-height: 150px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.badge.curl {
  color: #0a84ff;
  background: rgba(10, 132, 255, 0.1);
}
.badge.fetch {
  color: var(--purple);
  background: rgba(94, 92, 230, 0.12);
}
.badge.url {
  color: var(--green);
  background: rgba(52, 199, 89, 0.12);
}
.badge.unknown {
  color: var(--text-3);
}

/* ---------- 请求编辑器 ---------- */

.req-line {
  display: flex;
  gap: 10px;
}

.req-line select {
  width: 120px;
  flex: none;
  font-weight: 600;
}

.req-line input {
  flex: 1;
}

.headers-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.header-row input {
  flex: 1;
}
.header-row .hk {
  font-family: var(--mono);
  font-size: 12px;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  color: var(--red);
  border-color: rgba(255, 59, 48, 0.4);
  background: rgba(255, 59, 48, 0.08);
}

.add-link {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: inherit;
}
.add-link:hover {
  text-decoration: underline;
}

/* ---------- 响应 ---------- */

.resp-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.status-pill {
  font-weight: 600;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--mono);
}
.status-2 {
  color: var(--green);
  background: rgba(52, 199, 89, 0.14);
}
.status-3 {
  color: var(--blue);
  background: rgba(10, 132, 255, 0.14);
}
.status-4 {
  color: var(--orange);
  background: rgba(255, 159, 10, 0.16);
}
.status-5 {
  color: var(--red);
  background: rgba(255, 59, 48, 0.14);
}
.status-0 {
  color: var(--text-2);
  background: var(--surface-2);
}

.meta-item {
  font-size: 12px;
  color: var(--text-2);
}
.meta-item b {
  color: var(--text);
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
  width: fit-content;
}
.tab {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  border: none;
  background: none;
  font-family: inherit;
  transition: all 0.15s ease;
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 500;
}

.resp-pane {
  display: none;
}
.resp-pane.active {
  display: block;
}

pre.resp-body {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  max-height: 440px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.kv {
  font-family: var(--mono);
  font-size: 12.5px;
}
.kv .row {
  display: flex;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
}
.kv .k {
  color: var(--accent);
  min-width: 200px;
  flex: none;
}
.kv .v {
  color: var(--text);
  word-break: break-word;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- Toast ---------- */

.toast-wrap {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  animation: toastIn 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  max-width: 90vw;
}
.toast.error {
  background: rgba(255, 59, 48, 0.95);
}
.toast.success {
  background: rgba(52, 199, 89, 0.95);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hidden {
  display: none !important;
}

/* ---------- 格式转换 ---------- */

.fmt-group {
  margin-bottom: 4px;
}

.fmt-group-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.fmt-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.fmt-pill {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.fmt-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.fmt-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.fmt-note {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
  margin: 12px 0 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

#codeOutput {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
}

.hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 选项卡导航 ---------- */

.tabnav {
  display: flex;
  gap: 8px;
  margin: 20px 0 4px;
  flex-wrap: wrap;
}

.tabnav-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tabnav-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.tabnav-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---------- 条件字段 ---------- */

.sch-cond {
  animation: pop 0.25s ease;
}

/* ---------- 任务 / 结果卡片 ---------- */

.task-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface-2);
}

.task-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.task-name {
  font-weight: 600;
  font-size: 14px;
}

.task-meta {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
}

.task-actions {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.task-hist {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.run-row {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
  padding: 3px 0;
  font-family: var(--mono);
}

.run-row .ok {
  color: var(--green);
}

.run-row .fail {
  color: var(--red);
}

/* 小型 select（定时发送） */
select.sm {
  width: auto;
  flex: none;
  font-size: 13px;
  padding: 7px 10px;
  font-weight: 500;
}

/* 重试区 */
.retry-box {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--surface-2);
}
.retry-box > summary {
  cursor: pointer;
  user-select: none;
}
.retry-body {
  margin-top: 12px;
}
.retry-cond {
  animation: pop 0.2s ease;
}
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}
.checkbox-line input {
  width: auto;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
