:root {
  color-scheme: dark;
  --bg: #090b0e;
  --outer: #05070a;
  --panel: #11151a;
  --panel-2: #151b22;
  --assist: #151b24;
  --predict: #111827;
  --flow: #121316;
  --line: #313942;
  --line-strong: #46515d;
  --text: #e5e7eb;
  --muted: #a8a59f;
  --status: #f0c75e;
  --gold: #d5a762;
  --red: #ff5d69;
  --blue: #5ca5ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top, rgba(22, 30, 38, 0.92), rgba(5, 7, 10, 0.98) 54%, #030405),
    var(--outer);
  color: var(--text);
  font-family:
    "Segoe UI",
    "Malgun Gothic",
    system-ui,
    sans-serif;
}

body.flow-chart-open {
  overflow: hidden;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 5px 0 7px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.history-link {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 5px 10px;
  border: 1px solid rgba(213, 167, 98, 0.58);
  border-radius: 7px;
  color: #f1d19f;
  background: rgba(213, 167, 98, 0.09);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

.history-link:hover,
.history-link:focus-visible {
  border-color: var(--gold);
  color: #fff0d5;
  background: rgba(213, 167, 98, 0.17);
  outline: none;
}

.brand-title {
  width: 100%;
  font-size: clamp(19px, 1.8vw, 28px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.brand-title i {
  margin: 0 7px;
  color: var(--muted);
  font-style: normal;
}

.brand-mark {
  color: #101318;
  background: var(--gold);
  border-radius: 6px;
  padding: 2px 7px 4px;
}

.brand-rest {
  display: inline-flex;
  align-items: center;
  padding: 2px 0 4px;
  color: var(--text);
}

.runline {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.runline span {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.runline b {
  margin-left: 3px;
  color: var(--text);
}

.assist-zone,
.prediction-zone,
.flow-zone {
  position: relative;
  margin-top: 15px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.assist-zone {
  border-color: transparent;
}

.zone-label,
.zone-sub {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  margin-bottom: 5px;
  padding: 3px 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  font-size: 17px;
  font-weight: 950;
}

.live-badge,
.flow-state {
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  color: #241b05;
  background: var(--status);
  font-size: 10px;
  font-style: normal;
  font-weight: 950;
}

.ticker-card .live-badge,
.predict-card > .live-badge,
.flow-card .live-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  margin-left: 0;
}

.flow-state.closed {
  color: #aeb8c5;
  background: rgba(174, 184, 197, 0.1);
}

.flow-state.live {
  background: var(--status);
}

.zone-sub {
  margin-top: 5px;
}

.ticker-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.ticker-card,
.predict-card,
.flow-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #20252b;
}

.live-card {
  border-color: rgba(240, 199, 94, 0.78);
  background: #252629;
  box-shadow: none;
}

.ticker-card {
  min-height: 56px;
  padding: 5px 6px;
}

.ticker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.ticker-head span,
.predict-name small,
.flow-head span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.ticker-head em {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 999px;
  color: #aeb8c5;
  background: rgba(174, 184, 197, 0.1);
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.ticker-head .live-badge {
  color: #241b05;
  background: var(--status);
}

.ticker-card.live-card .ticker-head {
  padding-right: 34px;
}

.ticker-card strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(14px, 1.2vw, 21px);
  line-height: 1.02;
  text-align: center;
}

.ticker-card small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.prediction-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.extra-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
}

.predict-card {
  min-height: 102px;
  padding: 15px 6px 6px;
  border-color: rgba(92, 165, 255, 0.32);
}

.predict-card.compact {
  min-height: 56px;
  border-color: rgba(242, 189, 95, 0.3);
}

.predict-card.live-card,
.flow-card.live-card,
.ticker-card.live-card {
  border-color: rgba(240, 199, 94, 0.78);
}

.predict-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-height: 16px;
  justify-content: center;
}

.predict-name b {
  font-size: clamp(11px, 0.82vw, 14px);
  font-weight: 950;
  line-height: 1.08;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.predict-value {
  margin-top: 4px;
  font-size: clamp(17px, 1.55vw, 27px);
  line-height: 1.02;
  font-weight: 950;
  text-align: center;
  word-break: keep-all;
}

.main-card .predict-value {
  font-size: clamp(21px, 1.85vw, 31px);
}

.compact .predict-value {
  font-size: clamp(15px, 1.15vw, 21px);
}

.predict-sub {
  min-height: 14px;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.predict-compare {
  max-width: calc(100% - 6px);
  margin: 8px auto 0;
  padding: 5px 6px 4px;
  border: 1px solid rgba(125, 190, 255, 0.42);
  border-radius: 7px;
  background: rgba(7, 13, 22, 0.52);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.predict-basis {
  margin-top: 0;
  color: #ccd6dd;
  font-size: 12px;
  font-weight: 950;
  line-height: 1.1;
  text-align: center;
}

.main-card .predict-sub {
  font-size: 19px;
  line-height: 1.05;
}

.predict-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

.predict-meta span {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 10px;
  font-weight: 850;
}

.main-card .predict-meta {
  flex-wrap: nowrap;
  gap: 2px;
}

.main-card .predict-meta span {
  padding: 1px 4px;
  font-size: 9px;
  white-space: nowrap;
}

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

.down {
  color: var(--blue);
}

.flat {
  color: var(--muted);
}

.flow-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}

.flow-toolbar strong {
  display: inline-flex;
  align-items: center;
  padding: 3px 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
}

.flow-toolbar label,
.legend {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.legend {
  margin-left: auto;
  text-align: right;
}

.flow-toolbar input,
.flow-toolbar button {
  height: 25px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #181d23;
  font-weight: 850;
}

.flow-toolbar input {
  padding: 0 7px;
}

.flow-toolbar button {
  padding: 0 8px;
  cursor: pointer;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 3px 0 7px;
  border-radius: 2px;
  vertical-align: -1px;
}

.legend .buy {
  background: var(--red);
}

.legend .sell {
  background: var(--blue);
}

.flow-card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.flow-card {
  min-height: 148px;
  padding: 6px;
  border-color: rgba(242, 189, 95, 0.26);
  overflow: visible;
  cursor: pointer;
  transition: background-color 140ms ease, box-shadow 140ms ease;
}

.flow-card:hover {
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 0 0 1px rgba(240, 199, 94, 0.2);
}

.flow-card:focus-visible {
  outline: 2px solid var(--status);
  outline-offset: 2px;
}

.flow-card.detail-open {
  min-height: 186px;
}

.flow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 18px;
}

.flow-head b {
  font-size: 13px;
}

.flow-bars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 7px;
}

.flow-bar-row {
  display: grid;
  grid-template-columns: 58px minmax(42px, 1fr) 74px;
  align-items: center;
  gap: 5px;
  min-height: 21px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  font-weight: 900;
}

.flow-bar-row b,
.other-toggle {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.other-toggle {
  width: 100%;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.flow-other-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 3px;
  margin-top: 4px;
  padding: 5px;
  border: 1px solid rgba(242, 189, 95, 0.32);
  border-radius: 7px;
  background: rgba(20, 16, 10, 0.96);
  box-shadow: inset 0 0 0 1px rgba(242, 189, 95, 0.08);
}

.flow-other-detail[hidden] {
  display: none;
}

.flow-other-detail span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  justify-content: space-between;
  gap: 5px;
  font-size: 10px;
  font-weight: 900;
  min-width: 0;
}

.flow-other-detail b {
  color: var(--muted);
  white-space: nowrap;
}

.flow-other-detail em {
  font-style: normal;
  white-space: nowrap;
}

.flow-bar-row span {
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.flow-axis {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.flow-axis .zero {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(244, 241, 232, 0.45);
  z-index: 2;
}

.flow-axis .bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  max-width: 50%;
  border-radius: 999px;
}

.flow-axis .bar.up {
  background: var(--red);
}

.flow-axis .bar.down {
  background: var(--blue);
}

.flow-axis .bar.flat {
  background: var(--muted);
}

.flow-chart-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(1, 3, 6, 0.84);
  backdrop-filter: blur(4px);
}

.flow-chart-modal[hidden] {
  display: none;
}

.flow-chart-dialog {
  width: min(1120px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #101419;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
}

.flow-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.flow-chart-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  line-height: 1.2;
}

.flow-chart-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.flow-chart-close {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #1b2128;
  font-size: 24px;
  line-height: 28px;
  cursor: pointer;
}

.flow-chart-close:hover,
.flow-chart-close:focus-visible {
  border-color: var(--status);
  outline: none;
}

.flow-chart-legend {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  margin-top: 12px;
}

.flow-series-toggle {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 1px 6px;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 5px 7px;
  border: 1px solid color-mix(in srgb, var(--series) 55%, #303740);
  border-radius: 6px;
  color: var(--text);
  background: color-mix(in srgb, var(--series) 10%, #151a20);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.flow-series-toggle i {
  grid-row: 1 / span 2;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series);
}

.flow-series-toggle span,
.flow-series-toggle b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-series-toggle span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.flow-series-toggle b {
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
}

.flow-series-toggle.muted {
  border-color: var(--line);
  opacity: 0.42;
  background: #14181d;
}

.flow-chart-plot {
  position: relative;
  height: clamp(320px, 55vh, 520px);
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b0f13;
  overflow: hidden;
}

.flow-chart-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-grid,
.chart-x-tick {
  stroke: rgba(174, 184, 197, 0.13);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-x-tick {
  stroke-dasharray: 3 7;
}

.chart-zero {
  stroke: rgba(229, 231, 235, 0.5);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

.chart-axis-label {
  fill: #929ba6;
  font-size: 13px;
  font-weight: 750;
}

.chart-series {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-last-point {
  stroke: #0b0f13;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-cursor {
  stroke: rgba(240, 199, 94, 0.72);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.chart-hit-area {
  fill: transparent;
  pointer-events: all;
}

.flow-chart-tooltip {
  position: absolute;
  top: 12px;
  z-index: 2;
  display: grid;
  min-width: 150px;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(15, 19, 24, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.flow-chart-tooltip[hidden] {
  display: none;
}

.flow-chart-tooltip strong {
  margin-bottom: 2px;
  color: var(--text);
  font-size: 12px;
}

.flow-chart-tooltip span {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.flow-chart-tooltip span i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.flow-chart-tooltip span b {
  color: var(--text);
  font-size: 10px;
}

.flow-chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-weight: 800;
}

.footer {
  margin-top: 5px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 780;
  text-align: center;
}

.footer p {
  margin: 2px 0;
  white-space: nowrap;
}

.footer a {
  color: var(--gold);
  text-decoration: none;
}

.empty {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 980px) {
  .ticker-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

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

  .flow-chart-legend {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    display: grid;
    justify-content: stretch;
  }

  .runline {
    position: static;
    transform: none;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    justify-content: stretch;
    width: 100%;
    font-size: 10px;
  }

  .runline span {
    min-width: 0;
    padding: 3px 4px;
    text-align: center;
    white-space: nowrap;
  }

  .ticker-strip {
    grid-template-columns: repeat(auto-fit, minmax(clamp(82px, 23vw, 120px), 1fr));
  }

  .prediction-grid,
  .extra-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 90px), 1fr));
  }

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

  .ticker-card {
    min-height: 54px;
    padding: 4px;
  }

  .ticker-card strong {
    font-size: clamp(12px, 3.6vw, 18px);
  }

  .ticker-card small,
  .ticker-head span,
  .ticker-head em,
  .ticker-head .live-badge {
    font-size: 8.5px;
  }

  .predict-card {
    min-height: 96px;
    padding: 14px 4px 5px;
  }

  .predict-card.compact {
    min-height: 58px;
  }

  .predict-name {
    min-height: 18px;
  }

  .predict-name b {
    font-size: 9px;
  }

  .predict-value {
    font-size: 15px;
  }

  .main-card .predict-value {
    font-size: 17px;
  }

  .compact .predict-value {
    font-size: 15px;
  }

  .predict-sub {
    font-size: 11px;
    line-height: 1.1;
  }

  .predict-basis {
    font-size: 10.5px;
  }

  .main-card .predict-sub {
    font-size: 13px;
  }

  .predict-meta span {
    font-size: 8.5px;
  }

  .main-card .predict-meta {
    flex-wrap: wrap;
  }

  .flow-card {
    min-height: 148px;
  }

  .flow-card.detail-open {
    min-height: 190px;
  }

  .flow-bar-row {
    grid-template-columns: 34px minmax(42px, 1fr) 68px;
    gap: 4px;
  }

  .flow-other-detail {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .flow-chart-modal {
    padding: 6px;
  }

  .flow-chart-dialog {
    max-height: calc(100vh - 12px);
    padding: 10px;
  }

  .flow-chart-head h2 {
    font-size: 16px;
  }

  .flow-chart-head p {
    font-size: 10px;
  }

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

  .flow-chart-plot {
    height: min(52vh, 410px);
  }

  .chart-axis-label {
    font-size: 24px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 12px, 1440px);
    padding-top: 6px;
  }

  .brand-title {
    line-height: 1.25;
  }

  .topbar {
    align-items: flex-start;
    padding-top: 42px;
  }

  .history-link {
    left: 0;
    top: 5px;
    transform: none;
  }

  .runline {
    top: 5px;
    right: 0;
    transform: none;
  }

  .ticker-card strong,
  .predict-value {
    text-align: center;
  }

  .footer p {
    white-space: normal;
  }
}

@media (max-width: 340px) {
  .ticker-strip,
  .flow-card-grid {
    grid-template-columns: 1fr;
  }

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