:root {
  --brand: #5904fb;
  --brand-soft: #f3ecff;
  --brand-dark: #4300c4;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #059669;
  --warn: #d97706;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7a4bff, var(--brand));
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  white-space: nowrap;
}
.api-badge.ok { background: #ecfdf5; color: var(--ok); }
.api-badge.offline { background: #fef3c7; color: var(--warn); }

/* 头部横幅 */
.hero {
  padding: 36px 0 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f5f7 100%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  align-items: center;
}

.pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero-desc {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.hero-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { border-color: var(--brand); color: var(--brand); }
.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* 小程序引流卡片 */
.mp-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.04);
}

.mp-qr-wrap {
  width: 112px;
  height: 112px;
  flex: none;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
}

.mp-qr-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mp-qr-fallback {
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
}
.mp-qr-icon { font-size: 26px; margin-bottom: 4px; }

.mp-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.mp-desc { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.mp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mp-tags span {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
}

/* 主工作区 */
.workspace {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 20px;
  padding-top: 8px;
  padding-bottom: 48px;
  align-items: start;
}

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s;
}
.tool-item:hover { border-color: #d6c2ff; transform: translateY(-1px); }
.tool-item.active {
  border-color: var(--brand);
  background: #faf6ff;
  box-shadow: 0 4px 14px rgba(89, 4, 251, 0.1);
}

.tool-ic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.tool-meta { min-width: 0; flex: 1; }
.tool-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 600;
}
.tool-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 右侧操作面板 */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 24px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title-row h2 { margin: 0; font-size: 20px; }
.panel-desc { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: var(--ok);
  font-weight: 600;
}
.badge.cloud { background: #e0f2fe; color: #0369a1; }

#panel-body { flex: 1; }

/* 表单与交互控件 */
.dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 16px;
  padding: 28px 18px;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.15s;
}
.dropzone:hover { border-color: var(--brand); background: #faf6ff; }
.dropzone input[type="file"] { display: none; }
.drop-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.drop-sub { font-size: 12px; color: var(--muted); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.field label { font-size: 13px; font-weight: 600; color: #374151; }

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Consolas, monospace; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  display: inline-block;
}

.result-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid var(--line);
}

.preview-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  margin: 12px auto 0;
  border: 1px solid var(--line);
  background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stat-box {
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.stat-val { font-size: 20px; font-weight: 700; color: var(--brand); }
.stat-lbl { font-size: 12px; color: var(--muted); }

.notice-err {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
}

.panel-promo {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}

.footer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 20px 0;
  font-size: 13px;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}
.footer-links { display: flex; gap: 8px; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  max-width: 380px;
  width: 100%;
  padding: 26px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal-card h3 { margin: 0 0 8px; }
.modal-card p { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  font-size: 20px;
  cursor: pointer;
}
.modal-qr {
  width: 210px;
  height: 210px;
  margin: 0 auto;
  border-radius: 16px;
  border: 1px dashed #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.modal-qr img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .tool-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .tool-item { min-width: 190px; }
  .hero h1 { font-size: 24px; }
}
