:root {
  --bg: #05070d;
  --bg-panel: #0c1220;
  --bg-panel2: #0f1830;
  --border: #1b2745;
  --border-bright: #2a3f6e;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --up: #ff3b4e;
  --down: #3b82f6;
  --gold: #ffd166;
  --text: #e7edf7;
  --text-dim: #7c88a3;
  --purple: #a78bfa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Share Tech Mono", "Consolas", monospace;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(34, 211, 238, 0.10), transparent 45%),
    radial-gradient(ellipse at 90% 10%, rgba(167, 139, 250, 0.08), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.015) 0px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: screen;
}

.topbar {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(12, 18, 32, 0.9), rgba(12, 18, 32, 0.4));
}

.topbar-inner {
  max-width: 2000px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-mark-svg {
  width: 66px;
  height: 66px;
  display: block;
  overflow: visible;
}

.bm-orbit {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  opacity: 0.55;
  transform-box: fill-box;
  transform-origin: center;
  animation: bm-spin 9s linear infinite;
}

.bm-star-main {
  fill: var(--cyan);
  filter: drop-shadow(0 0 3px rgba(34, 211, 238, 0.9));
  transform-box: fill-box;
  transform-origin: center;
  animation: bm-pulse 2.4s ease-in-out infinite;
}

.bm-star-sm {
  fill: var(--gold);
  transform-box: fill-box;
  transform-origin: center;
  animation: bm-twinkle 1.8s ease-in-out infinite;
}

.bm-star-sm-1 { animation-delay: 0.1s; }
.bm-star-sm-2 { animation-delay: 0.7s; fill: #fff; }
.bm-star-sm-3 { animation-delay: 1.2s; }

@keyframes bm-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes bm-pulse {
  0%, 100% { opacity: 0.85; filter: drop-shadow(0 0 2px rgba(34, 211, 238, 0.8)); }
  50% { opacity: 1; filter: drop-shadow(0 0 8px rgba(34, 211, 238, 1)); }
}

@keyframes bm-twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.2); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-name-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.brand-name {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 30px;
  color: var(--text);
  letter-spacing: 0.01em;
}

.brand-domain {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--cyan);
}

.brand-tagline {
  font-size: 15px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--up);
  display: inline-block;
  box-shadow: 0 0 5px 1px rgba(255, 59, 78, 0.8);
}

.clock-wrap {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}

.live-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 8px 2px rgba(255, 59, 78, 0.8);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.live-label {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 23px;
  letter-spacing: 0.15em;
  color: var(--up);
}

.clock {
  font-family: "Orbitron", sans-serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.7);
  letter-spacing: 0.05em;
  min-width: 210px;
  text-align: right;
}

.wrap {
  position: relative;
  z-index: 2;
  max-width: 2000px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero-flash {
  font-family: "Orbitron", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--up);
  text-shadow: 0 0 12px rgba(255, 59, 78, 0.7);
  animation: flash 1.4s ease-in-out infinite;
  margin: 0 0 10px;
}

@keyframes flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.hero-title {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(26px, 4.8vw, 41px);
  font-weight: 900;
  margin: 0 0 12px;
  color: var(--text);
  line-height: 1.3;
}

.hero-top20 {
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(34, 211, 238, 0.7);
}

.excl {
  color: var(--up);
}

.hero-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.hero-sub span {
  color: var(--text);
}

.error-banner {
  background: rgba(255, 59, 78, 0.1);
  border: 1px solid rgba(255, 59, 78, 0.4);
  color: var(--up);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--bg-panel), var(--bg-panel2));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.3s, box-shadow 0.3s;
  cursor: pointer;
  position: relative;
}

.row:hover {
  border-color: var(--border-bright);
}

.row.rank-1 {
  border-color: rgba(255, 209, 102, 0.5);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.12);
}

.row.flash-update {
  animation: rowFlash 0.7s ease-out;
}

@keyframes rowFlash {
  0% { box-shadow: 0 0 0px rgba(34, 211, 238, 0); background-color: rgba(34, 211, 238, 0.08); }
  100% { box-shadow: 0 0 0px rgba(34, 211, 238, 0); background-color: transparent; }
}

.rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "Orbitron", sans-serif;
  color: var(--cyan);
  flex-shrink: 0;
  width: 48px;
}

.row.rank-1 .rank { color: var(--gold); }
.row.rank-1 .rank-num { font-size: 26px; text-shadow: 0 0 14px rgba(255, 209, 102, 0.8); }

.rank-no {
  font-size: 10px;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

.rank-num {
  font-size: 20px;
  font-weight: 700;
}

.row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px;
}

.name-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.name {
  font-family: "Noto Sans KR", sans-serif;
  font-size: 38px;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code {
  font-size: 13px;
  color: var(--text-dim);
}

.price-inline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: "Noto Sans KR", sans-serif;
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 14px rgba(231, 237, 247, 0.35);
}

.price-num { font-variant-numeric: tabular-nums; }

.won {
  font-size: 15px;
  color: var(--text-dim);
  margin-right: 2px;
}

.change {
  font-size: 34px;
  font-weight: 700;
  display: inline-flex;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.change.up { color: var(--up); text-shadow: 0 0 12px rgba(255, 59, 78, 0.55); }
.change.down { color: var(--down); text-shadow: 0 0 12px rgba(59, 130, 246, 0.55); }
.change.flat { color: var(--text-dim); }

.amount-inline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.amount-val {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-family: "Noto Sans KR", sans-serif;
  font-size: 34px;
  font-weight: 700;
}

.strength-row {
  display: grid;
  grid-template-columns: 56px 72px 1fr;
  align-items: center;
  gap: 12px;
}

.strength-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
}

.gauge {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.gauge-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.gauge-fill.foreign {
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
}

.gauge-fill.inst {
  background: linear-gradient(90deg, #6d28d9, var(--purple));
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
}

.gauge-fill.negative {
  background: linear-gradient(90deg, #475569, #64748b);
  box-shadow: none;
}

.strength-val {
  font-family: "Noto Sans KR", sans-serif;
  font-size: 18px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.disclaimer {
  margin-top: 30px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: center;
  opacity: 0.8;
}

@media (max-width: 560px) {
  .row { gap: 10px; padding: 12px; }
  .rank { width: 36px; }
  .name { font-size: 17px; }
  .price-inline { font-size: 19px; }
  .amount-inline { margin-left: 0; flex-basis: 100%; }
}

/* ── 행 확장 / 상세 차트 패널 ───────────────────────────────── */

.row-wrapper { display: contents; }

.expand-chevron {
  position: absolute;
  right: 14px;
  bottom: 10px;
  font-size: 11px;
  color: var(--text-dim);
  transition: transform 0.25s;
}

.expand-chevron.open {
  transform: rotate(180deg);
  color: var(--cyan);
}

.detail-panel {
  grid-column: 1 / -1;
  margin: -2px 0 10px;
  padding: 14px 16px 6px;
  background: linear-gradient(135deg, var(--bg-panel), #0a1122);
  border: 1px solid var(--border-bright);
  border-top: none;
  border-radius: 0 0 12px 12px;
}

.row-wrapper:has(.detail-panel:not([hidden])) .row {
  border-radius: 12px 12px 0 0;
  border-bottom-color: transparent;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.seg-toggle {
  display: inline-flex;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  overflow: hidden;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  border-right: 1px solid var(--border-bright);
}

.seg-btn:last-child { border-right: none; }

.seg-btn.active {
  background: rgba(34, 211, 238, 0.15);
  color: var(--cyan);
}

.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.chk input { accent-color: var(--cyan); }

.toolbar-label {
  font-size: 11px;
  color: var(--text-dim);
}

.chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.lg { display: flex; align-items: center; gap: 5px; }
.lg-spacer { flex: 1 1 auto; }

.lg-box {
  width: 9px; height: 9px; border-radius: 2px; display: inline-block;
}
.lg-box.up { background: var(--up); }
.lg-box.down { background: var(--down); }
.lg-box.ci { background: rgba(16, 185, 129, 0.4); border: 1px solid var(--ci, #10b981); }

.lg-line {
  width: 14px; height: 0; border-top: 2px solid; display: inline-block;
}
.lg-line.ma5 { border-color: #fb923c; }
.lg-line.ma20 { border-color: #facc15; }
.lg-line.ma60 { border-color: #a78bfa; }
.lg-line.bull { border-top-style: dashed; border-color: #10b981; }
.lg-line.base { border-color: var(--cyan); }
.lg-line.bear { border-top-style: dashed; border-color: var(--up); }
.lg-line.foreign-momentum { border-top-style: dashed; border-color: var(--cyan); }
.lg-line.inst-momentum { border-top-style: dashed; border-color: var(--purple); }

.chart-canvas-wrap {
  position: relative;
}

.chart-canvas {
  width: 100%;
  height: 1000px;
  color: var(--text-dim);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-controls {
  position: absolute;
  right: 10px;
  bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

.zoom-controls button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(12, 18, 32, 0.9);
  border: 1px solid var(--border-bright);
  color: var(--cyan);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-controls button:hover {
  background: rgba(34, 211, 238, 0.15);
}

.forecast-note {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.75;
  margin: 4px 0 2px;
}

@media (max-width: 700px) {
  .toolbar-left, .toolbar-right { gap: 8px; }
}
