/* ── 全局 ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #222240;
  --border: #2a2a4a;
  --text: #e0e0f0;
  --text2: #8888aa;
  --accent: #6c5ce7;
  --accent2: #a855f7;
  --green: #00d68f;
  --red: #ff6b6b;
  --yellow: #ffd93d;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

body {
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ──────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 36px; width: auto; }
.version { font-size: 12px; color: var(--text2); background: var(--surface2); padding: 2px 8px; border-radius: 20px; }
.status-bar { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.status-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); display: inline-block; }
.status-bar .dot.ok { background: var(--green); }
.status-bar .dot.err { background: var(--red); }

/* ── Layout ──────────────────────────────── */
.main { display: flex; height: calc(100vh - 64px); }
.sidebar {
  width: 260px; min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
  overflow-y: auto;
}
.content { flex: 1; padding: 28px; overflow-y: auto; }

/* ── Tabs ────────────────────────────────── */
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tab {
  background: transparent;
  border: none;
  color: var(--text2);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}
.tab:hover { background: var(--surface2); color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

/* ── API Config ──────────────────────────── */
.api-config { border-top: 1px solid var(--border); padding-top: 16px; }
.api-config h4 { font-size: 12px; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.api-config label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 6px; }
.api-config input {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; font-size: 12px;
  margin-top: 4px;
  font-family: inherit;
}
.key-status { font-size: 11px; margin-left: 6px; }

/* ── Buttons ─────────────────────────────── */
.btn {
  background: var(--accent); color: #fff;
  border: none; padding: 10px 22px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.btn:hover { background: var(--accent2); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); background: var(--surface2); }

/* ── Upload Zone ─────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all .3s;
  background: var(--surface);
  margin-bottom: 20px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--surface2);
}
.upload-zone.has-file {
  border-color: var(--green);
  border-style: solid;
  background: rgba(0, 214, 143, 0.06);
}
.upload-zone .icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone .title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.upload-zone .hint { font-size: 13px; color: var(--text2); }

/* ── Cards / Results ─────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 { font-size: 16px; margin-bottom: 12px; }
.panel-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

.param-row {
  display: flex; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; align-items: end;
}
.param-group { display: flex; flex-direction: column; gap: 4px; }
.param-group label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.param-group select, .param-group input[type=number] {
  padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; font-size: 14px; font-family: inherit;
}

.result-list { list-style: none; }
.result-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.result-item:last-child { border-bottom: none; }
.result-item .ok { color: var(--green); }
.result-item .err { color: var(--red); }

/* ── Text Rewrite ────────────────────────── */
.text-input {
  width: 100%; min-height: 150px;
  padding: 14px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; resize: vertical;
  margin-bottom: 12px;
}
.text-output {
  width: 100%; min-height: 120px;
  padding: 14px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  font-size: 14px; white-space: pre-wrap; word-break: break-word;
}

/* ── Toast ───────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow); animation: slideIn .3s ease;
  max-width: 400px;
}
.toast.success { background: #1a3a2a; border: 1px solid var(--green); color: var(--green); }
.toast.error { background: #3a1a1a; border: 1px solid var(--red); color: var(--red); }
.toast.info { background: #1a1a3a; border: 1px solid var(--accent); color: var(--accent2); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Progress bar ────────────────────────── */
.progress-bar {
  width: 100%; height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden; margin: 8px 0;
}
.progress-bar .fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px; transition: width .5s ease;
}

/* ── Pipeline flow ───────────────────────── */
.pipeline-steps { display: flex; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.pipeline-step {
  flex: 1; min-width: 120px;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface2); text-align: center;
  font-size: 13px;
}
.pipeline-step .step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; margin-bottom: 8px;
}
.pipeline-step.done .step-num { background: var(--green); }
.pipeline-step.active .step-num { animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  .main { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar .tabs { flex-direction: row; flex-wrap: nowrap; }
  .sidebar .api-config { display: none; }
}
