@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg: #05050a;
  --panel: rgba(22, 22, 34, 0.55);
  --panel-solid: #14141f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eceef5;
  --text-dim: #8b8ca3;
  --accent: #5b8cff;
  --accent2: #a066ff;
  --accent3: #ff5fa8;
  --long-liq: #ff4d6a;
  --short-liq: #2fe89b;
  --green: #2fe89b;
  --red: #ff4d6a;
  --yellow: #ffd23f;
  --radius: 14px;
  --font-ui: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- ambient background ---------- */

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 12% -5%, rgba(91, 140, 255, 0.16), transparent 60%),
    radial-gradient(700px 500px at 88% 10%, rgba(160, 102, 255, 0.14), transparent 60%),
    radial-gradient(900px 600px at 50% 110%, rgba(255, 95, 168, 0.08), transparent 60%);
  animation: driftGlow 18s ease-in-out infinite alternate;
}

@keyframes driftGlow {
  0% { filter: hue-rotate(0deg) brightness(1); }
  100% { filter: hue-rotate(20deg) brightness(1.08); }
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 0%, black 40%, transparent 90%);
}

/* ---------- topbar ---------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
  backdrop-filter: blur(10px);
}

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

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 16px rgba(91, 140, 255, 0.7);
  animation: markPulse 2.4s ease-in-out infinite;
}

@keyframes markPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(91, 140, 255, 0.6); }
  50% { transform: scale(1.25); box-shadow: 0 0 22px rgba(160, 102, 255, 0.9); }
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.grad-text {
  background: linear-gradient(90deg, var(--accent), var(--accent2) 60%, var(--accent3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 100%;
  animation: gradShift 6s ease-in-out infinite;
}

@keyframes gradShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  transition: color 0.3s, border-color 0.3s;
}

.live-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
}

.live-badge.on {
  color: var(--short-liq);
  border-color: rgba(47, 232, 155, 0.4);
}

.live-badge.on .dot {
  background: var(--short-liq);
  animation: dotPulse 1.5s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47, 232, 155, 0.65); }
  70% { box-shadow: 0 0 0 6px rgba(47, 232, 155, 0); }
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s, background 0.25s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 4px 16px rgba(91, 140, 255, 0.35);
}

/* ---------- layout ---------- */

main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  padding: 16px 24px 20px;
  display: flex;
}

.view {
  display: none;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  width: 100%;
  animation: viewIn 0.35s ease both;
}

.view.active { display: flex; }

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px 0;
}

/* ---------- controls bar ---------- */

.controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap { position: relative; }

#symbolInput {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  width: 230px;
  font-size: 14px;
  font-family: var(--font-ui);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#symbolInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}

.suggestions {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.suggestions .item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-mono);
  transition: background 0.15s;
}

.suggestions .item:hover { background: rgba(91, 140, 255, 0.14); }

.hidden { display: none !important; }

#intervalSelect {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
}

.zoom-controls {
  display: flex;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.zoom-controls button, .icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-family: var(--font-ui);
  transition: background 0.2s, transform 0.15s;
}

.zoom-controls button:hover, .icon-btn:hover {
  background: rgba(91, 140, 255, 0.16);
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--panel);
}

.icon-btn:active, .zoom-controls button:active { transform: scale(0.9); }

.price-ticker {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.price-ticker.flash-up {
  color: var(--green);
  border-color: rgba(47, 232, 155, 0.5);
  background: rgba(47, 232, 155, 0.08);
}

.price-ticker.flash-down {
  color: var(--red);
  border-color: rgba(255, 77, 106, 0.5);
  background: rgba(255, 77, 106, 0.08);
}

/* ---------- chart ---------- */

.chart-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 16px;
  gap: 14px;
}

.legend {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

.legend-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}

#legendCanvas {
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(160, 102, 255, 0.25);
}

.chart-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

#chart {
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(ellipse 120% 100% at 50% 0%, #0d0d16 0%, #050508 100%);
  border-radius: 10px;
  cursor: grab;
}

#chart:active { cursor: grabbing; }

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 8, 0.55);
  border-radius: 10px;
}

.pulse-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(91, 140, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 15, 24, 0.96);
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ---------- footer ---------- */

.foot-panel {
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#statusText {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.methodology {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

.methodology a { color: var(--accent); }
.methodology em { color: var(--text); font-style: normal; }

/* ---------- fear & greed view ---------- */

.fng-top-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fng-panel {
  flex: 0 0 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px 20px;
  gap: 4px;
}

.fng-gauge-wrap {
  position: relative;
  width: 420px;
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fngGauge { position: absolute; inset: 0; }

.fng-value {
  position: absolute;
  bottom: 46px;
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  transition: color 0.6s ease;
  text-shadow: 0 0 28px currentColor;
}

.fng-label {
  position: absolute;
  bottom: 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.6s ease;
}

.fng-stats-panel {
  flex: 1;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 20px;
  gap: 14px;
}

.fng-range-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}

.fng-range {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.fng-range:hover { color: var(--text); }

.fng-range.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.fng-distribution {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fng-dist-row {
  display: grid;
  grid-template-columns: 110px 1fr 120px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.fng-dist-label { color: var(--text); font-weight: 600; }

.fng-dist-bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.fng-dist-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 8px currentColor;
}

.fng-dist-value {
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-align: right;
  font-size: 12px;
}

.fng-meta {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fng-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
}

.fng-meta-row span:last-child {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
}

.fng-history-panel {
  flex: 1;
  min-width: 320px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
}

#fngHistory {
  flex: 1;
  width: 100%;
}

@media (max-width: 900px) {
  .fng-top-row { flex-direction: column; }
  .fng-panel { flex: none; }
}

/* ---------- order book / whale view ---------- */

.ob-symbol-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.ob-hint {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 11px;
  color: var(--text-dim);
}

.whale-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.whale-threshold select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.ob-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
}

.ob-depth-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 12px;
}

#depthChart {
  flex: 1;
  width: 100%;
}

.ob-whale-panel {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.count-badge {
  display: inline-block;
  background: rgba(91, 140, 255, 0.16);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

.whale-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
}

.whale-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  animation: whaleIn 0.4s ease both;
}

.whale-item.buy { border-color: rgba(47, 232, 155, 0.35); }
.whale-item.sell { border-color: rgba(255, 77, 106, 0.35); }

.whale-item .side {
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  text-align: center;
  font-size: 10px;
}

.whale-item.buy .side { color: var(--green); background: rgba(47, 232, 155, 0.12); }
.whale-item.sell .side { color: var(--red); background: rgba(255, 77, 106, 0.12); }

.whale-item .notional { font-weight: 700; }
.whale-item .time { color: var(--text-dim); font-size: 10px; }

@keyframes whaleIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .ob-layout { flex-direction: column; }
  .ob-whale-panel { flex: 0 0 260px; }
}
