:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #0d1117;
  --panel-2: #11161d;
  --line: #202731;
  --line-soft: #171d25;
  --text: #f1f5f7;
  --muted: #8b96a5;
  --faint: #596574;
  --acid: #a9ff68;
  --cyan: #63d8ff;
  --red: #ff627d;
  --amber: #ffc15a;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 75% -20%, rgba(99, 216, 255, 0.08), transparent 33rem),
    var(--bg);
  font-family: var(--sans);
  font-size: 16px;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 68px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 13, 0.88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 13px;
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.brand b { color: var(--faint); font-weight: 400; }

.brand-mark {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  color: #071008;
  background: var(--acid);
  border-radius: 8px;
  font: 800 1.05rem/1 var(--mono);
  box-shadow: 0 0 24px rgba(169, 255, 104, 0.15);
}

.topbar-meta { display: flex; align-items: center; gap: 22px; }
.status, .utc-clock { color: var(--muted); font: 0.76rem/1 var(--mono); }
.status { display: flex; align-items: center; gap: 8px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 9px var(--acid); }

.workspace {
  min-height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.sidebar {
  padding: 25px 22px;
  border-right: 1px solid var(--line);
  background: rgba(10, 13, 18, 0.86);
}

.side-heading, .timeline-label, .timeline-ends, .data-card-head, .model-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow, .dataset-code, .control-group label, .timeline-control label,
.data-card-head, .context-index, .context-card small {
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow { color: var(--muted); font-size: 0.72rem; }
.dataset-code { color: var(--faint); font: 0.68rem/1 var(--mono); }

.control-group { margin-top: 27px; }
.control-group label, .timeline-control label { color: var(--muted); display: block; margin-bottom: 10px; font-size: 0.71rem; }

.segmented, .range-grid {
  display: grid;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090c11;
}

.segmented { grid-template-columns: repeat(2, 1fr); }
.range-grid { grid-template-columns: repeat(4, 1fr); }

.segmented button, .range-grid button {
  min-height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: 0.76rem/1 var(--mono);
  cursor: pointer;
  transition: 150ms ease;
}

.segmented button:hover, .range-grid button:hover { color: var(--text); background: var(--panel-2); }
.segmented button.active, .range-grid button.active { color: #071008; background: var(--acid); font-weight: 800; }

.timeline-control { margin-top: 27px; }
.timeline-label output { color: var(--text); font: 0.72rem/1 var(--mono); }
.timeline-control input { width: 100%; margin: 8px 0 7px; accent-color: var(--acid); cursor: ew-resize; }
.timeline-ends { color: var(--faint); font: 0.65rem/1 var(--mono); }

.data-card, .model-card {
  margin-top: 27px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(17, 22, 29, 0.96), rgba(10, 13, 18, 0.96));
}

.data-card-head { color: var(--muted); padding-bottom: 13px; border-bottom: 1px solid var(--line-soft); font-size: 0.68rem; }
.data-card-head strong { color: var(--acid); font-size: 0.68rem; }
.data-card dl { margin: 8px 0 0; }
.data-card dl div { display: flex; justify-content: space-between; padding-top: 9px; font-size: 0.78rem; }
.data-card dt { color: var(--faint); }
.data-card dd { margin: 0; color: #cbd2da; font-family: var(--mono); }

.model-card { border-left: 2px solid var(--cyan); }
.model-title span:first-child { font: 0.78rem/1 var(--mono); font-weight: 700; }
.model-state { padding: 4px 6px; border-radius: 4px; color: var(--amber); background: rgba(255, 193, 90, 0.1); font: 0.62rem/1 var(--mono); }
.model-card p { color: var(--muted); margin: 12px 0 0; font-size: 0.76rem; line-height: 1.6; }

.export-button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #34404d;
  border-radius: 7px;
  background: transparent;
  color: #cbd2da;
  font-size: 0.78rem;
  cursor: pointer;
}
.export-button:hover { border-color: var(--acid); color: var(--acid); }

.main-panel { min-width: 0; padding: 28px 30px 34px; }

.instrument-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.instrument-line { display: flex; align-items: center; gap: 12px; }
.instrument-line h1 { margin: 0; font-size: clamp(1.45rem, 2vw, 2rem); letter-spacing: -0.04em; }
.instrument-line span { padding: 5px 7px; border: 1px solid #2d3742; border-radius: 4px; color: var(--muted); font: 0.62rem/1 var(--mono); }
.instrument-head p { margin: 7px 0 0; color: var(--muted); font-size: 0.8rem; }

.quote-block { text-align: right; }
.quote-block strong { display: block; font: 1.7rem/1 var(--mono); letter-spacing: -0.04em; }
.quote-block span { display: inline-block; margin-top: 8px; font: 0.78rem/1 var(--mono); }
.positive { color: var(--acid) !important; }
.negative { color: var(--red) !important; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 10px; background: rgba(13, 17, 23, 0.72); overflow: hidden; }
.metrics article { padding: 16px 18px; border-right: 1px solid var(--line); }
.metrics article:last-child { border-right: 0; }
.metrics span, .metrics small { display: block; color: var(--muted); font-size: 0.71rem; }
.metrics strong { display: block; margin: 9px 0 6px; font: 1.05rem/1 var(--mono); }
.metrics small { color: var(--faint); font-size: 0.65rem; }

.chart-card { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(13, 17, 23, 0.76); overflow: hidden; }
.chart-toolbar { height: 47px; padding: 0 17px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.legend { display: flex; gap: 20px; color: var(--muted); font-size: 0.7rem; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 2px; display: inline-block; }
.legend-price { background: var(--acid); }
.legend-volume { background: #374656; }
.chart-range { color: var(--faint); font: 0.67rem/1 var(--mono); }

.chart-wrap { height: clamp(350px, 47vh, 540px); position: relative; }
#price-chart { width: 100%; height: 100%; display: block; }
.loading-state { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; color: var(--muted); font: 0.74rem/1 var(--mono); background: rgba(13, 17, 23, 0.9); }
.loading-state span { width: 28px; height: 2px; margin: auto; background: var(--acid); animation: pulse 850ms infinite alternate; }
@keyframes pulse { from { opacity: 0.25; transform: scaleX(.35); } to { opacity: 1; transform: scaleX(1); } }

.chart-tooltip { position: absolute; z-index: 4; min-width: 158px; padding: 10px 11px; border: 1px solid #354250; border-radius: 6px; background: rgba(7, 9, 13, 0.94); pointer-events: none; color: var(--muted); font: 0.66rem/1.65 var(--mono); box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.chart-tooltip strong { color: var(--text); }

.context-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.context-card { min-height: 126px; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); position: relative; overflow: hidden; }
.context-card::after { content: ""; position: absolute; top: 0; right: 0; width: 32px; height: 1px; background: var(--faint); }
.accent-card::after { background: var(--acid); box-shadow: 0 0 12px var(--acid); }
.context-index { position: absolute; right: 14px; top: 14px; color: var(--faint); font-size: 0.63rem; }
.context-card small { color: var(--muted); font-size: 0.62rem; }
.context-card strong { display: block; margin-top: 7px; font: 0.95rem/1 var(--mono); }
.context-card p { margin: 15px 0 0; color: var(--muted); font-size: 0.73rem; line-height: 1.55; max-width: 88%; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 230px minmax(0, 1fr); }
  .main-panel { padding: 24px 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics article:nth-child(2) { border-right: 0; }
  .metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .context-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { height: 60px; padding: 0 15px; }
  .brand span:last-child { display: none; }
  .utc-clock { display: none; }
  .workspace { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 15px; }
  .side-heading, .data-card, .model-card { display: none; }
  .control-group, .timeline-control { margin-top: 15px; }
  .control-group:first-of-type { margin-top: 0; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .timeline-control, .export-button { grid-column: 1 / -1; }
  .main-panel { padding: 20px 15px 28px; }
  .instrument-head { align-items: flex-start; }
  .quote-block strong { font-size: 1.35rem; }
  .metrics article { padding: 14px; }
  .chart-wrap { height: 390px; }
  .legend { gap: 12px; }
}

@media (max-width: 440px) {
  .topbar-meta .status { font-size: 0.66rem; }
  .instrument-head { display: block; }
  .quote-block { margin-top: 17px; text-align: left; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics strong { font-size: 0.92rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
