/* Market Galaxy — owner: galaxy (docs/ARCHITECTURE.md §5.3).
   The stage is always a dark "space" viewport (in both themes); the toolbar follows theme tokens. */

.gx-host {
  position: relative;
  min-height: 0;
}

.gx {
  --gx-bg: #04060d;
  --gx-up: var(--up, #ff4d5e);
  --gx-down: var(--down, #1fcb7e);
  --gx-text: rgba(236, 241, 255, 0.95);
  --gx-axis: rgba(170, 184, 220, 0.72);
  --gx-grid: rgba(140, 162, 220, 0.075);
  --gx-ref: rgba(190, 205, 255, 0.3);
  --gx-note: rgba(196, 208, 240, 0.5);
  --gx-note-title: rgba(232, 238, 255, 0.78);
  --gx-label: rgba(222, 230, 252, 0.82);
  --gx-panel: rgba(8, 12, 26, 0.72);
  --gx-border: rgba(150, 172, 230, 0.16);
  --gx-font: var(--font-sans, "Noto Sans TC", "PingFang TC", system-ui, sans-serif);
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 420px;
  font-family: var(--gx-font);
  color: var(--text, #e7edf8);
  outline: none;
}

/* ---------- toolbar ---------- */
.gx-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, rgba(150, 172, 230, 0.11));
  background: var(--panel, rgba(14, 21, 39, 0.66));
  backdrop-filter: blur(var(--blur, 16px));
  -webkit-backdrop-filter: blur(var(--blur, 16px));
  font-size: var(--fs-sm, 12.5px);
  position: relative;
  z-index: 2;
}
.gx-spacer { flex: 1 1 auto; }

.gx-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-pill, 999px);
  background: var(--panel-2, rgba(22, 32, 58, 0.72));
  border: 1px solid var(--border, rgba(150, 172, 230, 0.11));
}
.gx-seg button,
.gx-chip,
.gx-toggle,
.gx-icon,
.gx-lasso-chip button {
  font: inherit;
  color: var(--text-2, #b9c4da);
  background: transparent;
  border: 0;
  cursor: pointer;
  border-radius: var(--r-pill, 999px);
  padding: 4px 11px;
  line-height: 1.35;
  transition: background var(--dur-1, 120ms), color var(--dur-1, 120ms), box-shadow var(--dur-2, 220ms);
  white-space: nowrap;
}
.gx-seg button:hover,
.gx-chip:hover,
.gx-toggle:hover,
.gx-icon:hover { color: var(--text, #e7edf8); background: var(--panel-hover, rgba(34, 48, 84, 0.55)); }
.gx-seg button[aria-pressed="true"] {
  color: var(--on-accent, #050814);
  background: var(--accent, #6c8cff);
  box-shadow: 0 0 16px -2px var(--accent-glow, rgba(108, 140, 255, 0.45));
}
.gx-seg-sm button { padding: 3px 9px; }
.gx-seg button:focus-visible,
.gx-chip:focus-visible,
.gx-toggle:focus-visible,
.gx-icon:focus-visible,
.gx-field select:focus-visible { outline: none; box-shadow: var(--ring, 0 0 0 2px #6c8cff); }

.gx-presets { display: inline-flex; gap: 4px; }
.gx-chip,
.gx-toggle {
  border: 1px solid var(--border, rgba(150, 172, 230, 0.11));
  padding: 3px 10px;
}
.gx-chip[aria-pressed="true"],
.gx-toggle[aria-pressed="true"] {
  color: var(--accent-strong, #8aa4ff);
  border-color: color-mix(in srgb, var(--accent, #6c8cff) 55%, transparent);
  background: var(--accent-soft, rgba(108, 140, 255, 0.16));
}
.gx-icon { padding: 3px 8px; font-size: 14px; border: 1px solid var(--border, rgba(150, 172, 230, 0.11)); }

.gx-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted, #8190ac);
}
.gx-field span { font-size: var(--fs-2xs, 10.5px); letter-spacing: 0.04em; font-weight: 600; }
.gx-field select {
  font: inherit;
  color: var(--text, #e7edf8);
  background: var(--panel-2, rgba(22, 32, 58, 0.72));
  border: 1px solid var(--border, rgba(150, 172, 230, 0.11));
  border-radius: var(--r-sm, 6px);
  padding: 3px 22px 3px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 11px) 55%, calc(100% - 7px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.gx-field select option { background: var(--panel-solid, #0d1427); color: var(--text, #e7edf8); }
.gx-field.gx-dim { opacity: 0.4; }

.gx-lasso-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: var(--r-pill, 999px);
  background: rgba(120, 170, 255, 0.14);
  border: 1px solid rgba(140, 190, 255, 0.4);
  color: var(--text, #e7edf8);
  animation: gx-pop var(--dur-3, 380ms) var(--ease-spring, cubic-bezier(0.34, 1.4, 0.64, 1));
}
.gx-lasso-chip[hidden] { display: none; }
.gx-lasso-chip button { padding: 2px 9px; background: rgba(255, 255, 255, 0.08); color: var(--text, #e7edf8); }
.gx-lasso-chip button:hover { background: rgba(255, 255, 255, 0.18); }
@keyframes gx-pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- stage ---------- */
.gx-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--gx-bg);
  isolation: isolate;
}
.gx-canvas {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.gx-up { color: var(--gx-up); }
.gx-down { color: var(--gx-down); }
.gx-muted { color: var(--gx-axis); }

.gx-rail {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 216px;
  display: grid;
  gap: 10px;
  pointer-events: none;
  z-index: 3;
}
.gx-hud {
  position: relative;
  padding: 10px 14px;
  border-radius: var(--r-md, 9px);
  background: var(--gx-panel);
  border: 1px solid var(--gx-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gx-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  min-width: 180px;
  box-shadow: 0 12px 40px -18px rgba(0, 0, 0, 0.8);
}
.gx-hud:empty { display: none; }
.gx-hud-date {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.gx-badge {
  font-family: var(--gx-font);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  color: #1b1200;
  background: #ffc862;
  box-shadow: 0 0 12px rgba(255, 200, 98, 0.5);
}
.gx-hud-row { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.gx-hud-note { margin-top: 6px; color: var(--gx-axis); font-size: 10.5px; }
.gx-ring-dot,
.gx-halo-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: -4px; }
.gx-ring-dot { border: 1.5px solid #ffd678; box-shadow: 0 0 8px rgba(255, 214, 120, 0.7); }
.gx-halo-dot { background: radial-gradient(circle, rgba(255, 206, 120, 0.8), rgba(255, 206, 120, 0) 70%); }

/* legend */
.gx-legend {
  position: relative;
  padding: 9px 12px 10px;
  border-radius: var(--r-md, 9px);
  background: var(--gx-panel);
  border: 1px solid var(--gx-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gx-text);
  font-size: 11px;
  pointer-events: none;
  display: grid;
  gap: 5px;
}
.gx-lg-title { color: var(--gx-axis); font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; }
.gx-lg-ramp { height: 7px; border-radius: 4px; width: 100%; }
.gx-lg-ticks { display: flex; justify-content: space-between; width: 100%; color: var(--gx-axis); font-size: 10px; font-variant-numeric: tabular-nums; }
.gx-lg-warn { color: #ffc862; font-size: 10.5px; }
.gx-lg-sizes { display: flex; align-items: flex-end; gap: 12px; }
.gx-lg-sizes span { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; color: var(--gx-axis); font-size: 10px; }
.gx-lg-sizes i { display: block; border-radius: 50%; background: radial-gradient(circle, #fff 0 20%, rgba(170, 190, 255, 0.55) 35%, rgba(170, 190, 255, 0) 72%); }
.gx-lg-sig { display: flex; gap: 10px; flex-wrap: wrap; color: var(--gx-axis); font-size: 10.5px; }
.gx-lg-sig span { display: inline-flex; align-items: center; gap: 4px; }
.gx-lg-sig i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }
.gx-lg-ring { border: 1.5px solid #ffd678; box-shadow: 0 0 6px rgba(255, 214, 120, 0.8); }
.gx-lg-halo { background: radial-gradient(circle, rgba(255, 206, 120, 0.85), rgba(255, 206, 120, 0) 70%); }
.gx-lg-watch { border: 1.5px solid #ffd75a; background: rgba(255, 255, 255, 0.85); transform: scale(0.8); }
.gx-lg-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.gx-lg-cats span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gx-lg-cats i { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.gx-lg-cats em { font-style: normal; color: var(--gx-axis); }

.gx-hint {
  padding: 0 4px;
  font-size: 10.5px;
  line-height: 1.7;
  color: rgba(170, 184, 220, 0.5);
}


/* tooltip */
.gx-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: 232px;
  padding: 10px 12px;
  border-radius: var(--r-md, 9px);
  background: rgba(8, 12, 26, 0.9);
  border: 1px solid rgba(160, 185, 245, 0.22);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--gx-text);
  font-size: 11.5px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  will-change: transform;
}
.gx-tip[hidden] { display: none; }
.gx-tip-head { display: flex; align-items: baseline; gap: 6px; }
.gx-tip-name { font-size: 14px; font-weight: 700; }
.gx-tip-code { font-family: var(--font-mono, ui-monospace, monospace); color: var(--gx-axis); }
.gx-tip-sub { color: var(--gx-axis); font-size: 10.5px; margin-top: 1px; }
.gx-tip-price { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.gx-tip-price b { font-size: 16px; font-family: var(--font-mono, ui-monospace, monospace); }
.gx-spark { display: block; width: 100%; height: 34px; margin-top: 6px; }
.gx-tip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(150, 172, 230, 0.14); }
.gx-tip-grid div { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; min-width: 0; }
.gx-tip-grid span { overflow: hidden; text-overflow: ellipsis; }
.gx-tip-rank { margin-left: auto; font-size: 11px; white-space: nowrap; }
.gx-tip-grid span { color: var(--gx-axis); }
.gx-tip-foot { margin-top: 7px; color: rgba(170, 184, 220, 0.55); font-size: 10px; }
.gx-chip-s { font-size: 10px; padding: 0 6px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--gx-text); }
.gx-chip-pass { border-color: #ffd678; color: #ffd678; }
.gx-chip-early { border-color: rgba(255, 206, 120, 0.5); color: rgba(255, 220, 160, 0.9); }
.gx-chip-hot { border-color: #ff8a5c; color: #ff8a5c; }

/* loading overlay */
.gx-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--gx-axis);
  font-size: 13px;
  background: radial-gradient(circle at 50% 45%, rgba(40, 60, 140, 0.25), transparent 60%);
  z-index: 4;
}
.gx-overlay[hidden] { display: none; }
.gx-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(140, 170, 255, 0.15);
  border-top-color: #8aa4ff;
  animation: gx-spin 0.9s linear infinite;
  box-shadow: 0 0 24px rgba(108, 140, 255, 0.35);
}
@keyframes gx-spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .gx-toolbar { gap: 6px; padding: 6px 8px; }
  .gx-presets { display: none; }
  .gx-rail { width: auto; top: 6px; right: 6px; }
  .gx-legend { display: none; }
  .gx-hud { min-width: 0; padding: 6px 9px; }
  .gx-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gx-spinner { animation-duration: 3s; }
  .gx-lasso-chip { animation: none; }
}
