:root {
  color-scheme: dark;
  --bg: #06080f;
  --bg-elevated: #0c1019;
  --surface: rgba(14, 20, 32, 0.72);
  --surface-strong: rgba(18, 26, 42, 0.92);
  --line: rgba(120, 160, 255, 0.14);
  --line-strong: rgba(120, 160, 255, 0.28);
  --text: #e8eef8;
  --muted: #8b9bb8;
  --accent: #3b9eff;
  --accent-2: #6ee7ff;
  --accent-glow: rgba(59, 158, 255, 0.35);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

[hidden], .is-hidden { display: none !important; }

html, body { height: 100%; }

body.app-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
  position: relative;
}

/* ── 科技背景层 ── */
.fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.72;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(110, 231, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 231, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 30%, black 20%, transparent 78%);
  animation: grid-drift 28s linear infinite;
}

.fx-scanlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(110, 231, 255, 0.35) 2px,
    rgba(110, 231, 255, 0.35) 3px
  );
}

.fx-data-stream {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  background:
    radial-gradient(circle at 15% 20%, rgba(59, 158, 255, 0.08) 0 1px, transparent 2px),
    radial-gradient(circle at 85% 35%, rgba(110, 231, 255, 0.06) 0 1px, transparent 2px),
    radial-gradient(circle at 45% 80%, rgba(59, 158, 255, 0.07) 0 1px, transparent 2px);
  background-size: 100% 100%;
  animation: stream-pulse 6s ease-in-out infinite;
}

.fx-lightning-flash {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 30% 20%, rgba(180, 230, 255, 0.14), transparent 55%);
  opacity: 0;
  animation: lightning-flash 9s ease-in-out infinite;
}

.bg-glow {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.55;
}

.bg-glow-a {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -80px;
  background: rgba(59, 158, 255, 0.22);
  animation: glow-float-a 14s ease-in-out infinite;
}

.bg-glow-b {
  width: 360px;
  height: 360px;
  right: -60px;
  bottom: 10%;
  background: rgba(110, 231, 255, 0.12);
  animation: glow-float-b 18s ease-in-out infinite;
}

@keyframes grid-drift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(48px, 48px); }
}

@keyframes stream-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.45; }
}

@keyframes lightning-flash {
  0%, 88%, 100% { opacity: 0; }
  89% { opacity: 0.55; }
  90% { opacity: 0.08; }
  91% { opacity: 0.42; }
  93% { opacity: 0; }
}

@keyframes glow-float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 20px) scale(1.08); }
}

@keyframes glow-float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-24px, -16px) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-grid,
  .fx-data-stream,
  .fx-lightning-flash,
  .bg-glow-a,
  .bg-glow-b {
    animation: none !important;
  }
  .fx-canvas { display: none; }
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 8, 15, 0.82);
  backdrop-filter: blur(16px);
}

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

.logo-mark {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
}

.logo-orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 20px var(--accent-glow);
  animation: orbit-spin 8s linear infinite;
}

.logo-core {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-text p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}

.status-pill.ok .pill-dot {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.status-pill.error .pill-dot {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 380px;
  gap: 18px;
  width: min(1480px, calc(100% - 32px));
  margin: 20px auto 32px;
}

.glass-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidebar, .result-panel { padding: 16px; }

.panel-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.nav-item:hover {
  border-color: var(--line-strong);
  background: rgba(255,255,255,0.03);
}

.nav-item.active {
  border-color: rgba(59, 158, 255, 0.45);
  background: linear-gradient(135deg, rgba(37,99,235,0.18), rgba(6,182,212,0.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(59,158,255,0.12);
  color: var(--accent-2);
  font-size: 14px;
}

.nav-copy strong {
  display: block;
  font-size: 14px;
}

.nav-copy small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.side-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
}

.section-title button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.section-title button:hover { color: var(--accent-2); }

.recent-list { display: grid; gap: 8px; }
.recent-list.empty { color: var(--muted); font-size: 13px; }

.recent-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}

.recent-item button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.recent-item button:hover { background: rgba(59,158,255,0.06); }

.recent-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.recent-meta span:first-child { color: var(--accent-2); font-weight: 600; }
.recent-meta span:last-child { color: var(--muted); }

.recent-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace { min-width: 0; padding: 20px; }

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

.view-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-heading h2 {
  margin: 6px 0 0;
  font-size: 24px;
  font-weight: 700;
}

.view { display: none; }
.view.active { display: block; }

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

label { display: grid; gap: 8px; }

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input, select { height: 44px; padding: 0 14px; }
textarea { min-height: 160px; padding: 12px 14px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: rgba(59,158,255,0.55);
  box-shadow: 0 0 0 3px rgba(59,158,255,0.15);
}

.span-2 { grid-column: span 2; }

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary-btn {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.45);
}

.primary-btn.compact { min-height: 40px; padding: 0 16px; }

.btn-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: btn-shine 4s ease-in-out infinite;
}

.ghost-btn-sm {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.ghost-btn-sm:not(:disabled):hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost-btn-sm:disabled { opacity: 0.45; cursor: not-allowed; }

.track-title { margin-bottom: 14px; }

.status-hero {
  position: relative;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(37,99,235,0.12), rgba(6,182,212,0.05));
  overflow: hidden;
}

.status-hero.idle { opacity: 0.85; }
.status-hero.active { border-color: rgba(59,158,255,0.4); }
.status-hero.success { border-color: rgba(52,211,153,0.4); background: var(--success-soft); }
.status-hero.error { border-color: rgba(248,113,113,0.35); background: var(--danger-soft); }

.status-ring {
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px solid rgba(59,158,255,0.2);
}

.status-hero.active .status-ring {
  animation: pulse-ring 2s ease-out infinite;
}

.status-hero-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-hero-inner h3 {
  margin: 8px 0 6px;
  font-size: 22px;
  font-weight: 700;
}

.status-hero-inner p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-summary { display: none; }

.polling-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(59,158,255,0.35);
  background: rgba(59,158,255,0.1);
  color: #bfdbfe;
  font-size: 12px;
}

.polling-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(191,219,254,0.25);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.result-panel.polling-active {
  box-shadow: 0 0 0 1px rgba(59,158,255,0.25), var(--shadow);
}

.status-detail {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.2);
}

.status-detail.empty {
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  font-size: 13px;
}

.detail-row dt {
  margin: 0;
  color: var(--muted);
}

.detail-row dd {
  margin: 0;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 12px;
}

.user-order-box {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.user-order-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.user-order-result {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.user-order-result.empty {
  color: var(--muted);
  font-size: 12px;
}

.user-order-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.user-order-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.user-order-card p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: var(--danger-soft); color: var(--danger); }

.json-box { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 480px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 0; }
}
@keyframes btn-shine {
  0%, 80% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .result-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    margin-top: 12px;
  }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .brand-text p { display: none; }
  .nav-item { min-height: auto; }
}
