/* === API Key 管家 — 墨刀级视觉 === */
:root {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --card-hover: #475569;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --input-bg: #0f172a;
  --input-border: #334155;
  --primary: #3b82f6;
  --primary-light: rgba(59,130,246,0.1);
  --purple: #8b5cf6;
  --green: #10b981;
  --green-light: rgba(16,185,129,0.08);
  --red: #ef4444;
  --red-light: rgba(239,68,68,0.08);
  --amber: #f59e0b;
  --amber-light: rgba(245,158,11,0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "SF Mono", monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.light {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --card-hover: #cbd5e1;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; outline: none; }

/* ===== Base Card ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

/* ===== Header ===== */
.header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
}
.header-inner {
  max-width: 1440px; margin: 0 auto; padding: 0 24px;
  height: 64px; display: flex; align-items: center; justify-content: space-between;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 10px; display: grid; place-items: center;
  color: #fff; font-size: 20px;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ===== Buttons ===== */
.btn {
  padding: 10px 20px; border-radius: var(--radius-md);
  font-weight: 600; font-size: 14px;
  transition: all var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; box-shadow: 0 2px 10px rgba(59,130,246,0.35);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59,130,246,0.5);
}

.btn-ghost {
  background: transparent; color: var(--text-muted);
  padding: 8px 14px; font-size: 13px; border-radius: 10px;
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--card-bg); color: var(--text-main); border-color: var(--card-border); }

.btn-slate {
  background: var(--card-bg); color: var(--text-main);
  border: 1px solid var(--card-border); padding: 8px 16px;
  font-size: 13px; font-weight: 600; border-radius: 10px;
}
.btn-slate:hover { border-color: var(--primary); background: var(--primary-light); }

/* ===== Layout ===== */
.main-body {
  max-width: 1440px; margin: 0 auto; padding: 24px 24px 80px;
}
.workspace-row {
  display: grid; grid-template-columns: 7fr 5fr; gap: 24px; align-items: start;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 10px;
}

/* ===== Input Card ===== */
.input-card { padding: 24px; }
.input-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.input-card-title {
  font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px;
}
.input-card-title iconify-icon { color: var(--primary); font-size: 22px; }

.input-card textarea {
  width: 100%; min-height: 140px; padding: 14px 16px;
  border-radius: var(--radius-md); border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--text-main);
  font-size: 14px; line-height: 1.6; resize: vertical; outline: none;
  transition: all var(--transition);
  scrollbar-width: none;
}
.input-card textarea::-webkit-scrollbar { width: 0; height: 0; }
.input-card textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.input-card textarea::placeholder { color: var(--text-dim); }

.input-status {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; font-size: 12px; color: var(--text-muted);
}
.status-badge {
  padding: 4px 12px; border-radius: 99px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
}
.status-badge.idle { background: var(--card-border); color: var(--text-muted); }
.status-badge.analyzing { background: rgba(59,130,246,0.15); color: var(--primary); }
.status-badge.ok { background: rgba(16,185,129,0.15); color: var(--green); }
.status-badge.warn { background: rgba(245,158,11,0.15); color: var(--amber); }

/* ===== Tool Card ===== */
.tool-card { padding: 24px; margin-top: 0; }
.tool-card-title {
  font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.tool-card-title iconify-icon { color: #f97316; font-size: 20px; }

.tool-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--card-border); background: var(--card-bg);
  width: 90px; cursor: pointer;
  transition: all var(--transition);
  font-size: 12px; font-weight: 600; color: var(--text-main);
}
.tool-btn:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-light), var(--card-bg) 50%);
  transform: translateY(-1px);
}
.tool-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1.5px var(--primary);
}
.tool-btn-icon { font-size: 24px; }
.tool-btn-label { font-size: 11px; }

/* ===== Verify Button ===== */
.verify-section { margin-top: 20px; }
.verify-btn {
  width: 100%; height: 56px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
  cursor: pointer; transition: all var(--transition);
}
.verify-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(59,130,246,0.55);
}
.verify-btn:active:not(:disabled) { transform: scale(0.98); }
.verify-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.verify-btn.success { background: linear-gradient(135deg, #059669, var(--green)); }
.verify-btn.error { background: linear-gradient(135deg, #dc2626, var(--red)); }

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

/* ===== Analysis Panel ===== */
.analysis-panel {
  display: grid; gap: 16px;
  position: sticky; top: 84px;
}

/* ===== Status Indicator ===== */
.status-indicator {
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
  border-left: 4px solid var(--card-border);
  transition: all 0.4s ease;
}
.status-indicator.idle { border-left-color: var(--text-dim); }
.status-indicator.analyzed { border-left-color: var(--primary); background: var(--primary-light); }
.status-indicator.loading { border-left-color: var(--purple); }
.status-indicator.success { border-left-color: var(--green); background: var(--green-light); }
.status-indicator.error { border-left-color: var(--red); background: var(--red-light); }

.status-icon-slot { font-size: 24px; flex-shrink: 0; }
.status-indicator.idle .status-icon-slot { color: var(--text-dim); }
.status-indicator.analyzed .status-icon-slot { color: var(--primary); }
.status-indicator.loading .status-icon-slot { color: var(--purple); animation: spin 1.5s linear infinite; }
.status-indicator.success .status-icon-slot { color: var(--green); }
.status-indicator.error .status-icon-slot { color: var(--red); }

.status-title { font-weight: 700; font-size: 14px; }
.status-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== Model Card (right panel) ===== */
.model-card { padding: 20px; }
.model-card-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 10px;
}

.model-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip {
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--card-border); background: var(--card-bg);
  font-size: 13px; font-weight: 600; color: var(--text-main);
  cursor: pointer; transition: all var(--transition);
}
.model-chip:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-light), var(--card-bg) 50%);
}
.model-chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* ===== Parse Results ===== */
.parse-card { padding: 20px; }
.parse-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 10px;
  background: var(--input-bg); border: 1px solid var(--card-border);
  margin-bottom: 8px; transition: background var(--transition);
}
.parse-row:last-child { margin-bottom: 0; }
.parse-row:hover { background: color-mix(in srgb, var(--primary-light), var(--input-bg) 80%); }
.parse-label { font-size: 12px; color: var(--text-muted); flex-shrink: 0; font-weight: 500; }
.parse-value { font-size: 13px; font-weight: 500; word-break: break-all; text-align: right; }
.parse-value.mono { font-family: var(--font-mono); font-size: 12px; }

/* ===== Error Card ===== */
.error-card {
  padding: 20px; border-color: rgba(239,68,68,0.25);
  background: linear-gradient(180deg, rgba(239,68,68,0.1), rgba(239,68,68,0.04));
}
.error-card-header {
  display: flex; align-items: center; gap: 10px; color: var(--red);
  font-weight: 700; font-size: 14px; margin-bottom: 12px;
}
.error-card-icon {
  width: 32px; height: 32px; border-radius: 10px;
  display: inline-grid; place-items: center;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.18);
}
.error-card-title {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
}
.error-list { list-style: none; font-size: 13px; color: var(--text-muted); line-height: 1.8; }
.error-list li { padding: 2px 0; display: flex; gap: 8px; }
.error-list li::before { content: "→"; color: var(--red); flex-shrink: 0; }
.error-list li.error-lead::before { content: ""; display: none; }
.error-list li.error-lead { display: block; padding: 0 0 10px; }
.error-lead strong { display: block; color: var(--text-main); font-size: 16px; margin-bottom: 4px; }
.error-lead-desc { color: var(--text-muted); font-size: 13px; line-height: 1.7; }

/* ===== Tips Card ===== */
.tips-card {
  padding: 20px; border-color: rgba(59,130,246,0.15);
  background: var(--primary-light);
}
.tips-card-header {
  display: flex; align-items: center; gap: 10px;
  color: var(--primary); font-weight: 700; font-size: 13px;
  margin-bottom: 8px;
}
.tips-card-body { font-size: 13px; color: var(--text-muted); line-height: 1.7; }

/* ===== Result Area Headings ===== */
.result-heading {
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--text-main); margin: 0 0 6px;
  display: flex; align-items: center; gap: 10px;
}
.result-heading iconify-icon { font-size: 22px; }
.result-heading-badge {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 6px;
  background: var(--primary-light); color: var(--primary);
}
.result-subheading {
  font-size: 13px; color: var(--text-muted); margin: 0 0 18px;
}

.result-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-top: 28px; opacity: 0.4; pointer-events: none;
  transition: opacity 0.5s ease;
}
.result-grid.active { opacity: 1; pointer-events: auto; }

/* ===== Step Guide ===== */
.result-step-card { padding: 28px; }
.step-list { position: relative; }
.step-item {
  display: flex; gap: 16px; padding-bottom: 28px; position: relative;
}
.step-item:last-child { padding-bottom: 0; }
.step-num {
  flex-shrink: 0; width: 36px; height: 36px;
  border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; z-index: 1;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}
.step-body { flex: 1; }
.step-body-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.step-body-desc { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.step-body-hint {
  margin-top: 10px; padding: 14px 16px; border-radius: 10px;
  background: var(--input-bg); border: 1px solid var(--card-border);
  font-size: 13px; line-height: 2.2; white-space: pre-line;
  font-family: var(--font-mono);
}
.step-connector {
  position: absolute; left: 17px; top: 44px;
  width: 2px; height: calc(100% - 36px);
  background: linear-gradient(to bottom, var(--primary), var(--card-border));
}

/* ===== JSON Config ===== */
.json-header {
  display: flex; justify-content: flex-end; align-items: center;
}
.json-copy-btn { font-size: 12px; font-weight: 600; }

.json-path {
  margin: 10px 0; padding: 10px 14px; border-radius: 8px;
  background: var(--input-bg); border: 1px solid var(--card-border);
  font-size: 12px; color: var(--text-muted); line-height: 1.6;
}
.json-path code {
  color: var(--primary); background: var(--primary-light);
  padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono);
}

.json-block {
  padding: 16px; border-radius: 12px;
  background: #0b1121; color: #86efac; border: 1px solid rgba(59,130,246,0.15);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.8;
  overflow-x: auto; white-space: pre; max-height: 300px;
}
.json-block::selection { background: rgba(134,239,172,0.2); }

.json-download-btn {
  width: 100%; margin-top: 14px; padding: 14px; border-radius: 10px;
  border: 1px solid var(--card-border); background: var(--card-bg);
  font-size: 14px; font-weight: 600; display: flex; align-items: center;
  justify-content: center; gap: 8px; cursor: pointer;
  transition: all var(--transition);
}
.json-download-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

/* ===== Privacy Reminder ===== */
.privacy-reminder {
  margin-top: 14px; padding: 14px 16px; border-radius: 10px;
  background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.18);
  font-size: 13px; color: var(--text-muted); line-height: 1.7;
}
.privacy-reminder strong { color: var(--primary); font-weight: 700; }

/* ===== History ===== */
.history-row {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 20px;
}
.history-row::-webkit-scrollbar { height: 4px; }
.history-row::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 10px; }

.history-item {
  flex-shrink: 0; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--card-border); background: var(--card-bg);
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; gap: 10px;
}
.history-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.history-item-icon { color: var(--primary); font-size: 18px; }
.history-item-name { font-size: 12px; font-weight: 700; }
.history-item-time { font-size: 10px; color: var(--text-muted); }
.history-empty {
  flex-shrink: 0; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--card-border); background: var(--card-bg);
  font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 8px;
  opacity: 0.6;
}

/* ===== Guide Overlay ===== */
.guide-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
}
.guide-overlay.visible { display: block; }

.guide-highlight {
  position: fixed; border: 3px solid var(--primary);
  border-radius: 12px; z-index: 101; pointer-events: none;
  transition: all 0.4s ease;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
}

.guide-box {
  position: fixed; z-index: 102; background: var(--card-bg);
  border: 1px solid var(--card-border); border-radius: 16px;
  padding: 24px; width: 340px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.guide-box-header {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px;
}
.guide-box-title { font-weight: 700; font-size: 16px; }
.guide-dots { display: flex; gap: 5px; }
.guide-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--card-border); }
.guide-dot.active { background: var(--primary); }
.guide-box-body { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.7; }
.guide-box-footer { display: flex; justify-content: space-between; }
.guide-skip {
  font-size: 13px; color: var(--text-muted); background: none;
  border: none; cursor: pointer; padding: 8px 12px; border-radius: 8px;
}
.guide-skip:hover { color: var(--text-main); background: var(--card-bg); }

/* ===== Troubleshooting Bottom ===== */
.trouble-bottom-card {
  margin-top: 24px; padding: 20px;
  border: 1px solid var(--card-border);
}
.trouble-bottom-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  transition: opacity var(--transition);
}
.trouble-bottom-toggle:hover { opacity: 0.8; }
.trouble-bottom-toggle-icon { font-size: 18px; }
.trouble-bottom-toggle-text { font-size: 14px; font-weight: 700; flex: 1; }
.trouble-bottom-toggle-arrow { font-size: 12px; color: var(--text-muted); }

.trouble-bottom-body { margin-top: 16px; }
.trouble-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.trouble-table td { padding: 8px 12px 8px 0; vertical-align: top; }
.trouble-table td:first-child { white-space: nowrap; width: 50px; }
.error-code-badge {
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
  font-family: var(--font-mono);
}
.ec-400 { background: rgba(245,158,11,0.15); color: var(--amber); }
.ec-401 { background: rgba(239,68,68,0.15); color: var(--red); }
.ec-404 { background: rgba(245,158,11,0.15); color: var(--amber); }
.ec-429 { background: rgba(239,68,68,0.15); color: var(--red); }
.ec-5xx { background: rgba(239,68,68,0.15); color: var(--red); }

/* ===== Footer ===== */
.footer {
  margin-top: 40px; padding: 24px;
  text-align: center; font-size: 12px; color: var(--text-dim);
  border-top: 1px solid var(--card-border);
}

/* ===== Banner ===== */
.banner-card { padding: 14px 18px; margin-top: 12px; border-radius: 10px; }
.info-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  padding: 16px;
}
.info-card.good { border-color: rgba(16,185,129,0.25); background: var(--green-light); }
.info-card.warn { border-color: rgba(245,158,11,0.25); background: var(--amber-light); }
.info-card.error { border-color: rgba(239,68,68,0.25); background: var(--red-light); }
.info-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.info-text { color: var(--text-muted); line-height: 1.7; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .workspace-row { grid-template-columns: 1fr; }
  .analysis-panel { position: static; }
  .result-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main-body { padding: 16px 14px 48px; }
  .result-step-card { padding: 20px; }
  .input-card, .tool-card { padding: 18px; }
  .tool-btn { width: 80px; padding: 12px 8px; }
}
