/* ============================================
   Trace — Global Styles
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --cyan: #06b6d4;
  --emerald: #10b981;
  --purple: #8b5cf6;
  --red: #ef4444;
  --text: #f0f0f5;
  --text-dim: rgba(255,255,255,0.4);
  --glass-bg: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.1);
  --radius: 16px;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================
   Particle Background
   ============================================ */

#particle-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ============================================
   Aurora Orbs
   ============================================ */

.aurora-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-orb {
  position: absolute;
  border-radius: 50%;
}

.orb-1 {
  width: 45vw; height: 45vw;
  top: -12%; left: -10%;
  background: radial-gradient(circle, rgba(6,182,212,0.12) 0%, transparent 70%);
  filter: blur(80px);
  animation: drift1 20s ease-in-out infinite;
}

.orb-2 {
  width: 38vw; height: 38vw;
  top: 50%; right: -8%;
  background: radial-gradient(circle, rgba(16,185,129,0.1) 0%, transparent 70%);
  filter: blur(80px);
  animation: drift2 25s ease-in-out infinite;
}

.orb-3 {
  width: 32vw; height: 32vw;
  bottom: -5%; left: 30%;
  background: radial-gradient(circle, rgba(139,92,246,0.08) 0%, transparent 70%);
  filter: blur(80px);
  animation: drift3 22s ease-in-out infinite;
}

@keyframes drift1 {
  0%,100% { transform: translate(0,0) scale(1); }
  25%     { transform: translate(10%,-15%) scale(1.1); }
  50%     { transform: translate(-5%,10%) scale(0.95); }
  75%     { transform: translate(-15%,-5%) scale(1.05); }
}

@keyframes drift2 {
  0%,100% { transform: translate(0,0) scale(1); }
  25%     { transform: translate(-12%,8%) scale(1.08); }
  50%     { transform: translate(8%,-12%) scale(0.92); }
  75%     { transform: translate(5%,15%) scale(1.03); }
}

@keyframes drift3 {
  0%,100% { transform: translate(0,0) scale(1); }
  25%     { transform: translate(15%,5%) scale(0.95); }
  50%     { transform: translate(-10%,-8%) scale(1.1); }
  75%     { transform: translate(8%,-15%) scale(1.0); }
}

/* ============================================
   Glass Card
   ============================================ */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

/* ============================================
   Layout
   ============================================ */

.container {
  position: relative;
  z-index: 10;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

/* ============================================
   Header
   ============================================ */

.header {
  text-align: center;
  margin-bottom: 4px;
}

.brand {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.tagline {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* ============================================
   Search
   ============================================ */

.search-card {
  width: 100%;
  padding: 16px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.search-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(6,182,212,0.1);
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: rgba(6,182,212,0.5);
}

.icon-search {
  flex-shrink: 0;
  width: 18px; height: 18px;
  color: rgba(255,255,255,0.3);
}

#keyword-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.9375rem;
  padding: 10px 0;
  font-family: inherit;
}

#keyword-input::placeholder {
  color: rgba(255,255,255,0.25);
}

.btn-glow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  color: white;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.3s;
  animation: glow-pulse 3s ease-in-out infinite;
}

.btn-glow:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(6,182,212,0.5), 0 0 60px rgba(16,185,129,0.25);
}

.btn-glow:active { transform: translateY(0); }

.btn-glow:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}

.icon-arrow {
  width: 20px; height: 20px;
}

@keyframes glow-pulse {
  0%,100% { box-shadow: 0 0 16px rgba(6,182,212,0.25), 0 0 32px rgba(16,185,129,0.12); }
  50%     { box-shadow: 0 0 24px rgba(6,182,212,0.4), 0 0 48px rgba(16,185,129,0.2); }
}

/* Suggestions */

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-left: 2px;
}

.chip {
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.45);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.chip:hover {
  background: rgba(6,182,212,0.12);
  border-color: rgba(6,182,212,0.25);
  color: var(--cyan);
  transform: translateY(-1px);
}

/* ============================================
   State Panels
   ============================================ */

.state-panel {
  width: 100%;
  animation: fadeSlideIn 0.4s ease-out;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Loading */

#state-loading {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loader-ring {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(6,182,212,0.2);
  border-top-color: var(--cyan);
  animation: spin 1s linear infinite;
  position: relative;
}

.loader-ring::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(6,182,212,0.5);
  animation: spin 1.5s linear infinite reverse;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
  color: var(--text-dim);
  font-size: 0.875rem;
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%,100% { opacity: 0.5; }
  50%     { opacity: 1; }
}

.loader-bar {
  width: 160px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}

.loader-bar-inner {
  height: 100%;
  width: 60%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  animation: pulse-text 2s ease-in-out infinite;
}

/* Error */

#state-error {
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.error-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(239,68,68,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-weight: 700;
  font-size: 1rem;
}

.error-text {
  color: rgba(239,68,68,0.8);
  font-size: 0.875rem;
}

.btn-retry {
  padding: 6px 20px;
  border-radius: 8px;
  border: 1px solid rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
  color: rgba(239,68,68,0.85);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-retry:hover {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
}

/* ============================================
   Result
   ============================================ */

.result-card {
  padding: 24px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.result-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(6,182,212,0.12);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.result-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}

.result-badge {
  font-size: 0.6875rem;
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(6,182,212,0.12);
  color: var(--cyan);
  border: 1px solid rgba(6,182,212,0.2);
}

.canvas-wrap {
  margin: 0 -8px;
  margin-bottom: 20px;
}

#curve-canvas {
  width: 100%;
  display: block;
}

/* Stats Bar */

.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-item {
  text-align: center;
  padding: 12px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.stat-label {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.35);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
}

.stat-value.positive { color: var(--emerald); }
.stat-value.negative { color: var(--red); }

.stat-change-icon {
  display: inline-block;
  width: 14px; height: 14px;
  vertical-align: middle;
  margin-right: 2px;
}

/* ============================================
   Footer
   ============================================ */

.footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 24px 0;
  margin-top: auto;
}

.footer p {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.15);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 480px) {
  .brand { font-size: 2rem; }
  .search-card { padding: 12px; }
  .result-card { padding: 16px; }
  .stats-bar { gap: 6px; }
  .stat-item { padding: 10px 4px; }
  .stat-value { font-size: 0.8125rem; }
}
