:root {
  --bg: #070b14;
  --panel: #0f1626;
  --panel-2: #131c30;
  --line: #1e2a42;
  --text: #eef3ff;
  --muted: #8b9bb8;
  --accent: #3d8bfd;
  --up: #ff4d4f;
  --down: #14c45a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "DIN Alternate", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.theme-light {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #dce2ec;
  --text: #172033;
  --muted: #657086;
  background: var(--bg);
}

body.theme-light .chart-topbar { background: rgba(255, 255, 255, 0.96); }
body.theme-light .toolbar,
body.theme-light .panel-hd { background: var(--panel-2); }
body.theme-light .symbol-box select,
body.theme-light .button-group,
body.theme-light .icon-button { background: #fff; }
body.theme-light .button-group button:hover,
body.theme-light .icon-button:hover { background: rgba(23, 32, 51, 0.06); }

button,
select { font: inherit; }

.chart-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.chart-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #0a0f1c;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.back:hover { color: var(--text); }
.brand { font-size: 14px; font-weight: 700; letter-spacing: 0.04em; }

.status {
  margin-left: auto;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.status.online { color: #86efac; border-color: #14532d; }
.status.error { color: #fca5a5; border-color: #7f1d1d; }

.chart-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: calc(100% - 20px);
  min-width: 0;
  min-height: 0;
  margin: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 9px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  scrollbar-width: thin;
}

.symbol-box select {
  width: 190px;
  height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #0b1220;
  color: var(--text);
}

.button-group {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1220;
}

.button-group button,
.icon-button {
  height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.button-group button:hover,
.icon-button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.button-group button.active { color: #fff; background: var(--accent); }
.indicators button.active { background: rgba(61, 139, 253, 0.2); color: #8dbbff; }

.icon-button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #0b1220;
  font-size: 16px;
}

.quote-header {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  min-height: 52px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line);
}

#quote-name { font-size: 14px; }
#quote-meta { margin-left: 7px; color: var(--muted); font-size: 11px; }
.ohlc { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.quote-change { margin-left: auto; font-size: 13px; font-weight: 700; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

.chart {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 260px;
}

.volume-label {
  position: absolute;
  left: 12px;
  bottom: 24px;
  z-index: 2;
  color: rgba(139, 155, 184, 0.72);
  font-size: 10px;
  pointer-events: none;
}

.quality-warning {
  position: absolute;
  top: 118px;
  left: 50%;
  z-index: 4;
  max-width: min(560px, calc(100% - 24px));
  padding: 8px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 8px;
  background: rgba(61, 43, 11, 0.92);
  color: #fcd34d;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
}

.chart-empty {
  position: absolute;
  inset: 110px 0 0;
  z-index: 3;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.chart-empty:not([hidden]) { display: grid; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.widget-branding {
  position: absolute;
  right: 8px;
  bottom: 4px;
  z-index: 5;
  color: var(--muted);
  font-size: 9px;
  text-decoration: none;
  opacity: 0.72;
}

body.widget-mode .chart-app { grid-template-rows: minmax(0, 1fr); }
body.widget-mode .chart-topbar { display: none; }
body.widget-mode .chart-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
}

@media (max-width: 720px) {
  .chart-topbar { min-height: 44px; padding: 6px 10px; }
  .brand { display: none; }
  .chart-shell { width: 100%; margin: 0; border-width: 0; border-radius: 0; }
  .toolbar { padding: 7px 8px; }
  .symbol-box select { width: 145px; }
  .indicators { display: none; }
  .quote-header { min-height: 48px; gap: 8px; padding: 7px 10px; }
  .ohlc { position: absolute; top: 101px; left: 10px; z-index: 2; pointer-events: none; }
  #quote-meta { display: block; margin: 2px 0 0; }
  .chart { min-height: 220px; }
}
