:root {
  color-scheme: dark;
  --bg: #0b0d0f;
  --panel: #111418;
  --line: #252a30;
  --line-strong: #38404a;
  --text: #f3f0e8;
  --muted: #8c949e;
  --accent: #f2b534;
  --up: #67c99a;
  --down: #ee756f;
  --axis-size: 86px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  margin: 0;
}

body {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 0%, rgba(242, 181, 52, 0.07), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

button {
  border: 0;
  padding: 6px 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
button:focus-visible {
  color: var(--text);
  outline: 1px solid #4b535d;
  outline-offset: -1px;
}

button.active {
  background: var(--accent);
  color: #17130a;
}

.app-header {
  position: relative;
  z-index: 50;
  min-width: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 15, 0.92);
}

.header-main,
.identity,
.quote,
.controls,
.interval-switch,
.range-switch,
.navigation-switch,
.chart-toolbar,
.toolbar-group,
.pane-readout,
.trade-panel-head {
  display: flex;
  align-items: center;
}

.header-main {
  min-width: 0;
  min-height: 62px;
  justify-content: space-between;
  gap: 20px;
  padding: 9px clamp(10px, 2vw, 28px) 8px;
}

.identity {
  min-width: 220px;
  gap: 10px;
}

.coin {
  max-width: 26vw;
  overflow: hidden;
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-block {
  min-width: 0;
}

.pair {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote {
  min-height: 28px;
  gap: 10px;
}

#price {
  font-size: clamp(18px, 2vw, 27px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.header-cursor-quote {
  min-width: 82px;
  display: grid;
  gap: 1px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.header-cursor-quote strong {
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
}

.header-cursor-quote.is-idle {
  visibility: hidden;
}

.positive {
  color: var(--up) !important;
}

.negative {
  color: var(--down) !important;
}

.controls {
  min-width: 0;
  justify-content: flex-end;
  gap: 8px;
}

.interval-switch,
.range-switch,
.navigation-switch,
.toolbar-group {
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  background: rgba(17, 20, 24, 0.82);
}

.interval-switch button,
.range-switch button,
.navigation-switch button {
  padding: 5px 7px;
}

.chart-toolbar {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 7px;
  padding: 0 clamp(10px, 2vw, 28px) 7px;
  overflow-x: auto;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.toolbar-group {
  min-height: 30px;
}

.toolbar-label {
  padding: 0 4px 0 2px;
  color: #65707c;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.overlay-button {
  --series-color: var(--accent);
}

.overlay-button.active {
  background: var(--series-color);
  color: #0b0d0f;
}

.overlay-button.darker {
  filter: saturate(0.75);
  opacity: 0.5;
}

.signal-button.active {
  background: #d7dce2;
  color: #111418;
}

.paper-switch {
  margin-left: auto;
}

#button_buy.active {
  background: var(--up);
}

#button_short.active {
  background: var(--down);
}

main {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 4px clamp(6px, 1.2vw, 18px) 8px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 18px;
}

.chart-workspace {
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 4fr) 1px minmax(94px, 1.15fr);
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(17, 20, 24, 0.74);
}

.price-pane,
.indicator-pane {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#price-chart,
#indicator-chart {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.pane-separator {
  background: var(--line);
}

.pane-readout {
  position: absolute;
  z-index: 20;
  top: 6px;
  left: 8px;
  max-width: calc(100% - var(--axis-size) - 16px);
  gap: 9px;
  padding: 3px 5px;
  overflow: hidden;
  background: rgba(11, 13, 15, 0.76);
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
}

.pane-readout strong {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 10px;
  letter-spacing: 0.05em;
}

#indicator-value {
  overflow: hidden;
  color: var(--accent);
  text-overflow: ellipsis;
}

.axis-cursor {
  position: absolute;
  right: 0;
  z-index: 30;
  width: var(--axis-size);
  padding: 4px 7px;
  transform: translateY(-50%);
  border-left: 2px solid currentColor;
  background: #171b20;
  box-shadow: 0 0 0 1px rgba(37, 42, 48, 0.95);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: right;
  pointer-events: none;
  white-space: nowrap;
}

.price-axis-cursor strong,
.price-axis-cursor span {
  display: block;
}

.price-axis-cursor strong {
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
}

.price-axis-cursor span {
  margin-top: 2px;
}

.indicator-axis-cursor {
  color: var(--accent);
}

.chart-tooltip {
  position: absolute;
  z-index: 40;
  max-width: min(520px, calc(100% - 100px));
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: rgba(11, 13, 15, 0.88);
  color: var(--text);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chart-status {
  align-self: end;
  padding: 4px 6px 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#error {
  position: absolute;
  inset: 10px;
  z-index: 100;
  padding: 16px;
  border: 1px solid rgba(238, 117, 111, 0.45);
  background: rgba(11, 13, 15, 0.96);
  color: var(--down);
  white-space: pre-wrap;
}

.trade-panel {
  position: absolute;
  z-index: 80;
  top: 12px;
  right: calc(clamp(6px, 1.2vw, 18px) + var(--axis-size));
  width: min(650px, calc(100% - var(--axis-size) - 28px));
  max-height: calc(100% - 40px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(11, 13, 15, 0.96);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.38);
}

.trade-panel-head {
  min-height: 32px;
  justify-content: space-between;
  padding-left: 9px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.table-scroll {
  max-height: calc(100dvh - 210px);
  overflow: auto;
}

#trade-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

#trade-table th,
#trade-table td {
  padding: 5px 7px;
  border: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

#trade-table th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--text);
}

.uplot {
  font-family: inherit;
}

.u-over {
  cursor: crosshair !important;
  touch-action: none;
}

.u-over.is-panning {
  cursor: grabbing !important;
}

.u-cursor-x,
.u-cursor-y {
  border: 0 !important;
}

.u-hz .u-cursor-x::after,
.u-hz .u-cursor-y::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.u-hz .u-cursor-x::after {
  inset: 0 auto 0 0;
  border-right: 1px dashed rgba(198, 208, 222, 0.48);
  transform: scaleX(0.8);
  transform-origin: center;
}

.u-hz .u-cursor-y::after {
  inset: 0 0 auto;
  border-bottom: 1px dashed rgba(198, 208, 222, 0.48);
  transform: scaleY(0.8);
  transform-origin: center;
}

@media (max-width: 1120px) {
  .header-main {
    min-height: 54px;
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    padding: 7px 8px 5px;
  }

  .identity {
    min-width: 0;
  }

  .primary-controls {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .chart-toolbar {
    padding: 0 8px 5px;
  }

  .paper-switch {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  :root {
    --axis-size: 68px;
  }

  .header-main {
    gap: 4px;
  }

  .coin {
    max-width: 42vw;
    font-size: 13px;
  }

  #price {
    font-size: 18px;
  }

  .header-cursor-quote {
    display: none;
  }

  .range-switch button:nth-child(1),
  .range-switch button:nth-child(2),
  .extended-interval,
  .toolbar-label {
    display: none;
  }

  .chart-workspace {
    grid-template-rows: minmax(0, 3.4fr) 1px minmax(100px, 1fr);
  }

  .pane-readout {
    left: 4px;
    max-width: calc(100% - var(--axis-size) - 8px);
    font-size: 9px;
  }

  .axis-cursor {
    padding-inline: 4px;
    font-size: 9px;
  }

  .trade-panel {
    right: 6px;
    left: 6px;
    width: auto;
  }
}
