:root {
  --bg: #08111a;
  --bg-soft: #0d1825;
  --panel: rgba(10, 21, 33, 0.92);
  --panel-strong: rgba(7, 16, 26, 0.96);
  --panel-border: rgba(173, 197, 216, 0.16);
  --panel-border-strong: rgba(173, 197, 216, 0.24);
  --text: #f4f8fb;
  --muted: #9aaebe;
  --accent: #f6c453;
  --accent-2: #8dbdd8;
  --green: #18c58f;
  --blue: #4d8dff;
  --red: #ff5e66;
  --orange: #ffc145;
  --teal: #28c7b7;
  --yellow: #f4d35e;
  --sky: #4f8cff;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.3);
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  background:
    radial-gradient(circle at top left, rgba(79, 140, 255, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(40, 199, 183, 0.12), transparent 24%),
    linear-gradient(180deg, #0b1521 0%, #08111a 52%, #071019 100%);
  min-height: 100vh;
}

input, textarea, select, [contenteditable] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.shell {
  width: 100%;
  margin: 0;
  padding: 0 0 56px;
}

.hero,
.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hero {
  border-radius: 28px;
  padding: 28px 30px;
  display: block;
  margin-bottom: 24px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    linear-gradient(180deg, rgba(17, 31, 47, 0.96), rgba(10, 20, 31, 0.96));
}

.hero-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.lang-switch {
  width: auto;
  min-width: 180px;
  justify-items: end;
}

.lang-switch span {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lang-switch select {
  min-width: 160px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 700;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.15rem, 4.6vw, 4.35rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.hero-copy,
.panel-heading p,
label span,
output,
.notes-list {
  color: var(--muted);
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  align-self: center;
}

.button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.rrg-control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
}

.scatter-pair-label {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
}

.scc-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.scc-button.is-active,
.scc-button:hover {
  border-color: rgba(142, 202, 230, 0.5);
  background: rgba(142, 202, 230, 0.12);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), #fb8500);
  color: #0d1117;
  font-weight: 700;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.auto-refresh-toggle,
.auto-refresh-interval {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text);
}

.rrg-control-bar .auto-refresh-toggle,
.rrg-control-bar .auto-refresh-interval {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  cursor: pointer;
}

.rrg-control-bar .auto-refresh-toggle:hover,
.rrg-control-bar .auto-refresh-interval:hover {
  border-color: rgba(142, 202, 230, 0.5);
  background: rgba(142, 202, 230, 0.12);
}

.auto-refresh-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.auto-refresh-interval select {
  background: rgba(5, 13, 21, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  min-width: 70px;
}

.auto-refresh-interval select:hover {
  border-color: var(--accent);
}

.auto-refresh-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.public-mode .controls,
body.public-mode .notes-panel,
body.public-mode .admin-login-panel {
  display: none;
}

body.admin-mode.admin-locked .controls,
body.admin-mode.admin-locked .notes-panel {
  display: none;
}

.file-button input {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
}

.panel {
  border-radius: 26px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)),
    var(--panel);
}

.admin-login-panel {
  border-style: dashed;
}

.admin-login-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-prediction-meta {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  color: var(--muted);
  font-size: 0.95rem;
}

.detail-prediction-meta strong {
  color: var(--text);
}

.is-hidden {
  display: none;
}

.controls,
.chart-panel {
  min-height: 320px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-bottom: 8px;
  font-size: clamp(1.28rem, 2vw, 1.7rem);
  letter-spacing: -0.02em;
}

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

.symbols {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.benchmark-box {
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.compact {
  margin-bottom: 10px;
}

.symbol-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.015));
}

.symbol-card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.dot-a { background: var(--teal); }
.dot-b { background: var(--yellow); }
.dot-c { background: var(--sky); }
.dot-d { background: #ff7a59; }
.dot-e { background: #c084fc; }
.dot-f { background: #7dd3fc; }
.dot-g { background: #f472b6; }
.dot-h { background: #a3e635; }

label,
output {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
}

.debug-toggle {
  align-content: end;
}

.debug-toggle input {
  width: auto;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(5, 13, 21, 0.94);
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(141, 189, 216, 0.55);
  box-shadow: 0 0 0 4px rgba(141, 189, 216, 0.14);
}

.chart-shell {
  width: 100%;
  aspect-ratio: 1.78 / 1;
  min-height: 620px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    rgba(3, 10, 16, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.main-chart-shell {
  aspect-ratio: 2 / 1;
  min-height: 800px;
}

.price-chart-shell {
  min-height: 480px;
}

.lightweight-chart {
  width: 100%;
  height: 100%;
  min-height: 480px;
}

.price-chart-timeframe {
  font-size: 0.875rem;
  color: var(--accent);
  font-weight: 600;
  padding: 8px 12px;
  background: rgba(142, 202, 230, 0.1);
  border-radius: 8px;
}

#chart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-overlay-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: none;
  flex-direction: column;
  gap: 10px;
}

.chart-overlay-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(7, 17, 27, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.node-nav-overlay {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.chart-shell:hover .node-nav-overlay {
  opacity: 1;
  pointer-events: auto;
}

.node-nav-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(7, 17, 27, 0.88);
  color: #7ab8d8;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  transition: background 0.15s, color 0.15s;
}

.node-nav-button:hover {
  background: rgba(30, 60, 100, 0.9);
  color: #4fc3f7;
}

.chart-tap-tooltip {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  max-width: min(78vw, 280px);
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(7, 17, 27, 0.94);
  color: var(--text);
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
  white-space: pre-line;
}

.countdown-overlay {
  width: 100%;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(7, 17, 27, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.countdown-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.countdown-row:hover {
  background: rgba(255, 255, 255, 0.08);
}

.countdown-row:active {
  background: rgba(255, 255, 255, 0.15);
}

.countdown-name {
  font-weight: 700;
}

.countdown-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.countdown-fill {
  height: 100%;
  border-radius: inherit;
}

.countdown-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}

.table-wrap {
  overflow-x: auto;
}

.accordion {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.025);
}

.accordion summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  color: var(--text);
  font-weight: 500;
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion[open] summary {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.accordion .table-wrap {
  padding: 0 16px 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 500;
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: rgba(79, 195, 247, 0.08);
  cursor: default;
}

.notes-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.guide-panel,
.disclaimer-panel {
  position: relative;
}

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

.guide-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.015));
  min-height: 100%;
}

.guide-card h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.guide-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

code {
  color: var(--accent-2);
}

@media (max-width: 1280px) {
  .shell {
    width: min(100% - 28px, 1680px);
  }

  .layout {
    max-width: 100%;
  }

  .chart-shell {
    min-height: 560px;
  }

  .main-chart-shell {
    min-height: 620px;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 16px, 1680px);
  }

  .hero,
  .panel {
    border-radius: 20px;
  }

  .hero {
    padding: 22px;
  }

  .panel {
    padding: 18px;
  }

  .control-grid,
  .symbol-grid {
    grid-template-columns: 1fr;
  }

  .hero-topline {
    align-items: flex-start;
  }

  .lang-switch {
    width: 100%;
    justify-items: start;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .chart-shell {
    aspect-ratio: 1 / 1.06;
    min-height: 380px;
  }

  .main-chart-shell {
    aspect-ratio: 1 / 1.02;
    min-height: 430px;
  }

  .chart-overlay-controls {
    display: flex;
  }

  .price-chart-shell,
  .lightweight-chart {
    min-height: 380px;
  }

  .countdown-overlay {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Draggable Scatter Float Panel ───────────────────────── */
#scatterFloat {
  /* docked by default — floated state toggled by JS via .is-floating */
  position: relative;
  z-index: auto;
}

#scatterFloat.is-floating {
  position: fixed;
  z-index: 300;
  top: 80px;
  width: 820px;
  min-width: 420px;
  min-height: 320px;
  background: #08111a;
  border: 1px solid #1e3a50;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#scatterFloat.is-floating #scatterFloatBody {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0 12px 10px;
}

#scatterFloat.is-floating .main-chart-shell {
  flex: 1;
  min-height: 240px;
  aspect-ratio: unset;
}

#scatterDragHandle {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #0d2235;
  border-bottom: 1px solid #1e3a50;
  border-radius: 10px 10px 0 0;
  user-select: none;
  flex-shrink: 0;
}

#scatterFloat.is-floating #scatterDragHandle {
  display: flex;
  cursor: move;
}

/* ── Draggable Detail Panel (mirrors scatterFloat) ──────── */
#detailPanel {
  /* docked by default — floated state toggled by JS via .is-floating */
  position: relative;
  z-index: auto;
}

#detailPanel.is-floating {
  position: fixed;
  z-index: 301;
  top: 100px;
  width: 720px;
  min-width: 360px;
  min-height: 320px;
  background: #08111a;
  border: 1px solid #1e3a50;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#detailPanel.is-floating #detailFloatBody {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0 12px 10px;
}

#detailPanel.is-floating .chart-shell {
  flex: 1;
  min-height: 200px;
  aspect-ratio: unset;
}

#detailChart {
  width: 100%;
  height: 100%;
  display: block;
}

#detailDragHandle {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #0d2235;
  border-bottom: 1px solid #1e3a50;
  border-radius: 10px 10px 0 0;
  user-select: none;
  flex-shrink: 0;
}

#detailPanel.is-floating #detailDragHandle {
  display: flex;
  cursor: move;
}

#detailPanel.is-floating #detailFloatBtn {
  display: none;
}

/* ── Detail panel compact header ─────────────────────────── */
#detailCompactHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: nowrap;
}

#detailPanel #detailTitle {
  font-size: 11px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  color: #8bb8d0;
  letter-spacing: 0;
}

#detailCompactHeader select {
  font-size: 10px;
  padding: 1px 4px;
  background: #0a1929;
  color: #8bb8d0;
  border: 1px solid #2a5070;
  border-radius: 3px;
  cursor: pointer;
}

#detailPanel .detail-prediction-meta {
  font-size: 10px;
  padding: 2px 8px;
  margin-bottom: 3px;
  border-radius: 4px;
  line-height: 1.4;
}

/* ── Detail panel chart-shell ────────────────────────────── */
#detailPanel .chart-shell {
  min-height: 260px;
  aspect-ratio: 1000 / 640;
}

/* ── Detail chart row — docked: transparent wrapper; floating: side-by-side ── */
#detailChartRow {
  display: contents; /* invisible in docked mode — children join parent flex directly */
}
#detailPanel.is-floating #detailChartRow {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  gap: 6px;
}
#detailPanel.is-floating #detailChartRow .chart-shell {
  flex: 1;
  min-width: 0;
}
#detailPanel.is-floating .countdown-overlay {
  width: 90px;
  min-width: 80px;
  flex-shrink: 0;
  margin: 0;
  padding: 4px;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  gap: 4px;
  align-content: stretch;
  align-self: stretch;
  overflow: hidden;
  border-radius: 8px;
}
#detailPanel.is-floating .countdown-row {
  min-height: 0;
  overflow: hidden;
  justify-content: center;
}
#detailPanel.is-floating .countdown-row > div:first-child {
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: flex-start !important;
  gap: 1px !important;
}
#detailPanel.is-floating .countdown-name,
#detailPanel.is-floating .countdown-time {
  white-space: nowrap;
  overflow: visible;
  font-size: 10px;
  line-height: 1.3;
}
#detailPanel.is-floating #detailFloatBody {
  overflow-x: hidden;
}

/* ── Detail panel compact control bar ───────────────────── */
#detailPanel .rrg-control-bar {
  gap: 4px;
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 10px;
}

#detailPanel .scc-button {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 8px;
}

/* ── Last-node pulse ring ──────────────────────────────────── */
@keyframes last-node-pulse {
  0%   { opacity: 0.9;  transform: scale(1);   }
  70%  { opacity: 0;    transform: scale(3.5); }
  100% { opacity: 0;    transform: scale(3.5); }
}
.blink-last-node {
  transform-box: fill-box;
  transform-origin: center;
  animation: last-node-pulse 1.6s ease-out infinite;
  pointer-events: none;
}

@keyframes xhair-ring-pulse {
  0%   { opacity: 0.85; transform: scale(1);   }
  65%  { opacity: 0;    transform: scale(2.6); }
  100% { opacity: 0;    transform: scale(2.6); }
}
#rg-xhair-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: xhair-ring-pulse 1s ease-out infinite;
  pointer-events: none;
}

/* ── Draggable Debug Chart Panel (mirrors scatterFloat / detailPanel) ──── */
#debugFloat {
  position: relative;
  z-index: auto;
}

#debugFloat.is-floating {
  position: fixed;
  z-index: 302;
  top: 120px;
  width: 860px;
  min-width: 420px;
  min-height: 320px;
  background: #08111a;
  border: 1px solid #1e3a50;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#debugFloat.is-floating #debugFloatBody {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0 12px 10px;
}

#debugFloat.is-floating .price-chart-shell {
  flex: 1;
  min-height: 240px;
  aspect-ratio: unset;
  overflow: hidden;
}

#debugFloat.is-floating .panel-heading {
  display: none;
}

#debugFloat.is-floating #debugFloatBtn {
  display: none;
}

#debugDragHandle {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #0d2235;
  border-bottom: 1px solid #1e3a50;
  border-radius: 10px 10px 0 0;
  user-select: none;
  flex-shrink: 0;
}

#debugFloat.is-floating #debugDragHandle {
  display: flex;
  cursor: move;
}

/* ── RS Debug Panel (RSD / RSW) ─────────────────────────── */
#rsDebugPanel {
  background: rgba(10,18,28,0.6);
  border-top: 1px solid rgba(255,255,255,0.07);
}

#rsDebugDragHandle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #071420;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  user-select: none;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

#rsDebugBody {
  padding: 8px 12px 10px;
}

/* Floating state */
#rsDebugPanel.is-floating {
  position: fixed;
  display: flex !important;
  flex-direction: column;
  z-index: 302;
  top: 100px;
  right: 40px;
  left: auto;
  width: 520px;
  min-width: 360px;
  min-height: 420px;
  background: #08111a;
  border: 1px solid #1e3a50;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  overflow: hidden;
}

#rsDebugPanel.is-floating #rsDebugDragHandle {
  cursor: move;
  background: #0d2235;
  border-bottom: 1px solid #1e3a50;
  border-radius: 10px 10px 0 0;
}

#rsDebugPanel.is-floating #rsDebugBody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#rsDebugPanel.is-floating #rsTimeCanvas {
  min-height: 100px;
}

#rsRrgCanvas {
  aspect-ratio: 1;
}

#rsDebugPanel.is-floating #rsDebugFloatBtn {
  display: none;
}

/* ── Draggable Price Chart Panel ────────────────────────── */
#priceFloat {
  position: relative;
  z-index: auto;
}

#priceFloat.is-floating {
  position: fixed;
  z-index: 1000;
  top: 80px;
  left: 40px;
  width: 780px;
  min-width: 400px;
  min-height: 340px;
  background: #08111a;
  border: 1px solid #1e3a50;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#priceFloat.is-floating #priceFloatBody {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  padding: 0;
}

#priceFloat.is-floating .price-chart-shell {
  flex: 1;
  min-height: 0;
  aspect-ratio: unset;
  overflow: hidden;
}

#priceFloat.is-floating .lightweight-chart {
  width: 100%;
  height: 100%;
  min-height: 0;
}

#priceDragHandle {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #0d2235;
  border-bottom: 1px solid #1e3a50;
  border-radius: 10px 10px 0 0;
  user-select: none;
  flex-shrink: 0;
}

#priceFloat.is-floating #priceDragHandle {
  display: flex;
  cursor: move;
}

/* ── Float panel taskbar ─────────────────────────────────── */
#floatTabBar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  padding: 0 8px;
  z-index: 99999;
  align-items: flex-end;
}
.float-tab {
  padding: 4px 16px 3px;
  font-size: 11px;
  font-family: inherit;
  border-radius: 6px 6px 0 0;
  border: 1px solid #2a5070;
  border-bottom: none;
  background: rgba(7,17,27,0.92);
  color: #6a9ab0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  backdrop-filter: blur(6px);
}
.float-tab:hover {
  background: #0d2040;
  color: #d9e7ef;
}
.float-tab.is-active {
  background: #0d2a44;
  color: #d9e7ef;
  border-color: #3a7090;
}
.float-tab.is-minimized-tab {
  opacity: 0.55;
  border-style: dashed;
}
.float-tab.is-minimized-tab:hover {
  opacity: 0.85;
}
.float-tab-all {
  margin-left: 6px;
  border-left: 2px solid #2a5070;
  color: #a0b8c8;
  letter-spacing: 0.04em;
}
.float-tab-all:hover {
  background: #0d2040;
  color: #e8f4ff;
}
.float-tab-all.is-minimized-tab {
  color: #7a9ab0;
  border-color: #3a7090;
}
#chart.arrow-mode,
#chart.arrow-mode * {
  cursor: crosshair !important;
}
/* Minimized panel — hidden via inline style set by JS */

/* ── Corner resize handles for floating panels ───────────── */
.float-resize-handle {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 20;
  display: none;
}
.is-floating .float-resize-handle { display: block; }

.float-resize-se { right: 0;  bottom: 0; cursor: se-resize; border-radius: 0 0 10px 0; }
.float-resize-sw { left: 0;   bottom: 0; cursor: sw-resize; border-radius: 0 0 0 10px; }
.float-resize-ne { right: 0;  top: 0;    cursor: ne-resize; border-radius: 0 10px 0 0; }
.float-resize-nw { left: 0;   top: 0;    cursor: nw-resize; border-radius: 10px 0 0 0; }

.float-resize-handle::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  border-color: rgba(138,187,210,0.45);
  border-style: solid;
  border-width: 0;
  transition: border-color 0.15s;
}
.float-resize-handle:hover::before { border-color: rgba(138,187,210,0.9); }

.float-resize-se::before { right: 4px;  bottom: 4px; border-right-width: 2px; border-bottom-width: 2px; border-radius: 0 0 3px 0; }
.float-resize-sw::before { left: 4px;   bottom: 4px; border-left-width: 2px;  border-bottom-width: 2px; border-radius: 0 0 0 3px; }
.float-resize-ne::before { right: 4px;  top: 4px;    border-right-width: 2px; border-top-width: 2px;    border-radius: 0 3px 0 0; }
.float-resize-nw::before { left: 4px;   top: 4px;    border-left-width: 2px;  border-top-width: 2px;    border-radius: 3px 0 0 0; }

/* ═══════════════════════════════════════════════════════════
   Feature Showcase — scroll-based animated demo section
   ═══════════════════════════════════════════════════════════ */
.showcase-section {
  padding: 56px 24px 48px;
  border-bottom: 1px solid rgba(173,197,216,0.10);
  overflow: hidden;
}
.showcase-inner   { max-width: 1100px; margin: 0 auto; }
.showcase-header  { text-align: center; margin-bottom: 44px; }
.showcase-eyebrow {
  display: block; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.14em; color: #4fc3f7; margin-bottom: 10px;
  text-transform: uppercase;
}
.showcase-title {
  font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700;
  color: var(--text); margin: 0;
}
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
}

/* Card entrance animation (triggered by IntersectionObserver) */
.showcase-card {
  display: flex; flex-direction: column; gap: 14px;
  opacity: 0; transform: translateY(30px);
  transition: opacity 0.55s ease calc(var(--ri,0s)),
              transform 0.55s ease calc(var(--ri,0s));
}
.showcase-card.visible { opacity: 1; transform: translateY(0); }
.showcase-card h3 { margin: 0; font-size: 0.98rem; font-weight: 700; color: var(--text); }
.showcase-card p  { margin: 0; font-size: 0.76rem; color: var(--muted); line-height: 1.55; }

/* macOS-style fake window */
.showcase-window {
  background: #071420; border: 1px solid #1e3a50;
  border-radius: 9px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.showcase-win-bar {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 10px; background: #0c1c2d;
  border-bottom: 1px solid #1e3a50;
}
.win-dot { width: 9px; height: 9px; border-radius: 50%; }
.win-dot.r { background: #ff5f56; }
.win-dot.y { background: #ffbd2e; }
.win-dot.g { background: #27c93f; }
.win-title { font-size: 0.66rem; color: #8bb8d0; font-weight: 600; margin-left: 5px; letter-spacing: 0.04em; }
.showcase-win-body { padding: 0; }

/* ── Price chart mockup ─────────────────────────── */
.demo-price-svg { width: 100%; height: 110px; display: block; background: #06111c; }

@keyframes demoCandle {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.demo-candle {
  opacity: 0;
  animation: demoCandle 0.25s ease forwards calc(var(--cd, 0s));
}
@keyframes demoLabel {
  from { opacity: 0; } to { opacity: 1; }
}
.demo-struct { opacity: 0; animation: demoLabel 0.3s ease forwards calc(var(--ld, 0s)); }

@keyframes demoDivPulse {
  0%,100% { opacity: 0; }
  10%,85% { opacity: 0.85; }
}
.demo-div-ring  { animation: demoDivPulse 3.5s ease-in-out infinite 2.4s; }
.demo-div-arrow { animation: demoDivPulse 3.5s ease-in-out infinite 2.4s; }

@keyframes demoLastBar {
  0%,100% { transform: scaleY(1);   transform-origin: bottom; }
  50%      { transform: scaleY(0.6); transform-origin: bottom; }
}
.demo-forming { animation: demoLastBar 2.2s ease-in-out infinite 1.6s; }

/* ── RRG scatter mockup ─────────────────────────── */
.demo-rrg-svg { width: 100%; height: 150px; display: block; background: #06111c; }

/* ── PP Scanner mockup ─────────────────────────── */
.demo-scanner { font-family: monospace; font-size: 0.72rem; background: #06111c; }
.demo-scanner-hdr {
  display: grid; grid-template-columns: 1.8fr 1.1fr 1.1fr 1.1fr;
  padding: 5px 10px; color: #3a6a80;
  border-bottom: 1px solid #1a3048;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em;
}
.demo-scanner-row {
  display: grid; grid-template-columns: 1.8fr 1.1fr 1.1fr 1.1fr;
  padding: 5px 10px; border-bottom: 1px solid #0e1e2d;
  opacity: 0;
  animation: demoRowSlide 0.35s ease forwards calc(var(--ri, 0s));
}
@keyframes demoRowSlide {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes demoValueFlash {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.4; }
}
.demo-scanner-row .sym { color: #d0dde8; font-weight: 700; }
.demo-scanner-row .pos { color: #18c58f; }
.demo-scanner-row .neg { color: #ff5e66; }
.demo-scanner-row .flash { animation: demoValueFlash 0.6s ease calc(var(--fd,0s)); }

/* ── Scroll hint ─────────────────────────────── */
.showcase-hint {
  text-align: center; margin-top: 40px;
  color: #2d5a70; font-size: 0.78rem;
}
.showcase-hint-arrow {
  display: inline-block; margin-top: 6px; font-size: 1.3rem; color: #4fc3f7;
  animation: showcaseBounce 1.6s ease-in-out infinite;
}
@keyframes showcaseBounce {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(7px); opacity: 0.6; }
}

@media (max-width: 720px) {
  .showcase-section { padding: 40px 16px 36px; }
  .showcase-title   { font-size: 1.25rem; }
}
