:root {
  --bg-light: #f8fafc;
  --bg-dark: #0f172a;
  --glass-light: rgba(255, 255, 255, 0.72);
  --glass-dark: rgba(30, 41, 59, 0.72);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-light);
}
body.dark { background-color: var(--bg-dark); }

/* Mesh gradient background */
.mesh-bg {
  background:
    radial-gradient(at 20% 20%, hsla(250, 80%, 70%, 0.35) 0px, transparent 50%),
    radial-gradient(at 80% 10%, hsla(280, 80%, 65%, 0.25) 0px, transparent 45%),
    radial-gradient(at 10% 80%, hsla(190, 80%, 60%, 0.25) 0px, transparent 45%),
    radial-gradient(at 90% 80%, hsla(320, 80%, 70%, 0.25) 0px, transparent 45%),
    linear-gradient(135deg, #f5f7fa 0%, #eef2ff 100%);
  animation: meshMove 20s ease-in-out infinite alternate;
}
body.dark .mesh-bg {
  background:
    radial-gradient(at 20% 20%, hsla(250, 70%, 45%, 0.35) 0px, transparent 50%),
    radial-gradient(at 80% 10%, hsla(280, 70%, 40%, 0.25) 0px, transparent 45%),
    radial-gradient(at 10% 80%, hsla(190, 70%, 40%, 0.25) 0px, transparent 45%),
    radial-gradient(at 90% 80%, hsla(320, 70%, 45%, 0.25) 0px, transparent 45%),
    linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

@keyframes meshMove {
  0% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.05) translate(-1%, 1%); }
  100% { transform: scale(1) translate(1%, -1%); }
}

.noise {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.glass {
  background: var(--glass-light);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
body.dark .glass {
  background: var(--glass-dark);
  border-color: rgba(255, 255, 255, 0.08);
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
body.dark ::-webkit-scrollbar-thumb { background: #475569; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Platform chips */
.platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
body.dark .platform-chip {
  background: rgba(30, 41, 59, 0.6);
  border-color: #334155;
  color: #cbd5e1;
}
.platform-chip:hover { border-color: #818cf8; }
.platform-chip.active {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4338ca;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
body.dark .platform-chip.active {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Limit inputs */
.limit-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.6);
}
body.dark .limit-box {
  background: rgba(30, 41, 59, 0.6);
  border-color: #334155;
}
.limit-box input {
  width: 56px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: white;
  padding: 4px;
  font-size: 13px;
  outline: none;
}
body.dark .limit-box input {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

/* Steps */
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 70px;
  opacity: 0.45;
  transition: all 0.3s ease;
}
.step.active { opacity: 1; }
.step-dot {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: all 0.3s ease;
}
.step.active .step-dot { background: #6366f1; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }
.step.done .step-dot { background: #10b981; }
.step-label { font-size: 11px; color: #64748b; white-space: nowrap; }
body.dark .step-label { color: #94a3b8; }

/* Tabs */
.tab-btn {
  color: #64748b;
  background: transparent;
  border: none;
  cursor: pointer;
}
body.dark .tab-btn { color: #94a3b8; }
.tab-btn.active {
  background: white;
  color: #4338ca;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
body.dark .tab-btn.active {
  background: #1e293b;
  color: #c7d2fe;
}

/* Export buttons */
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 600;
  color: #4338ca;
  cursor: pointer;
  transition: all 0.15s ease;
}
.export-btn:hover {
  background: #eef2ff;
  border-color: #6366f1;
  transform: translateY(-1px);
}
.export-btn:active { transform: translateY(0); }
body.dark .export-btn {
  background: rgba(30, 41, 59, 0.7);
  border-color: #334155;
  color: #c7d2fe;
}
body.dark .export-btn:hover { background: rgba(99, 102, 241, 0.15); border-color: #6366f1; }

/* Log stream */
.log-entry { margin-bottom: 4px; }
.log-entry .ts { color: #64748b; margin-right: 6px; }
.log-entry .ok { color: #34d399; }
.log-entry .warn { color: #fbbf24; }
.log-entry .info { color: #60a5fa; }

/* Comment cards */
.comment-card {
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.6);
  padding: 14px 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
body.dark .comment-card {
  background: rgba(30, 41, 59, 0.5);
  border-color: #334155;
}
.comment-card:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.comment-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.comment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.comment-user { font-size: 12px; font-weight: 600; color: #475569; }
body.dark .comment-user { color: #94a3b8; }
.comment-idx { font-size: 11px; color: #94a3b8; }
.comment-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #6366f1;
  text-decoration: none;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comment-source:hover { text-decoration: underline; }
.comment-source svg { flex-shrink: 0; }
.comment-text { font-size: 13.5px; line-height: 1.65; color: #334155; }
body.dark .comment-text { color: #e2e8f0; }

/* Prose / Markdown report */
.md-h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; margin: 1.2em 0 0.6em; }
.md-h2 { font-size: 1.15rem; font-weight: 700; color: #334155; margin: 1em 0 0.5em; padding-bottom: 0.35em; border-bottom: 1px solid #e2e8f0; }
.md-h3 { font-size: 1rem; font-weight: 600; color: #4338ca; margin: 0.8em 0 0.4em; }
body.dark .md-h1 { color: #f1f5f9; }
body.dark .md-h2 { color: #e2e8f0; border-color: #334155; }
body.dark .md-h3 { color: #a5b4fc; }
.md-p { margin-bottom: 0.85em; color: #334155; line-height: 1.7; }
body.dark .md-p { color: #cbd5e1; }
.md-ul { margin: 0.6em 0 1em 1.4em; padding: 0; list-style: disc; }
.md-li { margin-bottom: 0.45em; color: #334155; line-height: 1.6; }
body.dark .md-li { color: #cbd5e1; }
.md-bold { font-weight: 700; color: #4338ca; }
body.dark .md-bold { color: #a5b4fc; }
.code-block {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 0.8em 0;
  color: #334155;
}
body.dark .code-block { background: #1e293b; color: #e2e8f0; }
.inline-code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 2px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #4338ca;
}
body.dark .inline-code { background: #1e293b; color: #a5b4fc; }

/* Prose (legacy) */
.prose p { margin-bottom: 0.8em; }
.prose ul { margin-left: 1.2em; margin-bottom: 0.8em; }
.prose li { margin-bottom: 0.35em; }
.prose strong { color: #4338ca; }
body.dark .prose strong { color: #a5b4fc; }

/* Animation delays */
.animation-delay-200 { animation-delay: 200ms; }
.animation-delay-400 { animation-delay: 400ms; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
body.dark .skeleton {
  background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
  background-size: 200% 100%;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
