:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #232c38;
  --text: #d7dee8;
  --dim: #8b949e;
  --up: #26a69a;
  --down: #ef5350;
  --accent: #c9a227;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

/* author display rules would otherwise defeat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}

/* ---------- banner ---------- */
.banner {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  padding: 6px 12px calc(6px + var(--safe-t));
  background: #7f1d1d; color: #fecaca;
  font-weight: 600; font-size: 12px; text-align: center;
  letter-spacing: .03em;
}
.banner.warn { background: #78350f; color: #fde68a; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: relative; z-index: 30;
  min-height: 46px;
  flex-wrap: wrap;
}

.sym { position: relative; }
.sym-btn {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font: inherit; font-weight: 700; font-size: 14px;
  padding: 5px 9px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.sym-btn:hover { border-color: #3b4654; }
.caret { color: var(--dim); font-size: 10px; }

.sym-list {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px;
  background: #1c2430; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 32px #0009; overflow: hidden; z-index: 50;
}
.sym-list button {
  display: flex; flex-direction: column; gap: 1px; width: 100%;
  padding: 8px 12px; background: none; border: 0; border-bottom: 1px solid #202834;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.sym-list button:last-child { border-bottom: 0; }
.sym-list button:hover { background: #232d3a; }
.sym-list .s { font-weight: 700; }
.sym-list .n { color: var(--dim); font-size: 11px; }

.quote { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.last { font-size: 16px; font-weight: 700; }
.chg { font-size: 12px; color: var(--dim); }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }

.tfs { display: flex; gap: 4px; margin-left: auto; }
.tfs button {
  background: none; border: 1px solid transparent; border-radius: 5px;
  color: var(--dim); font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 8px; cursor: pointer;
}
.tfs button:hover { color: var(--text); }
.tfs button[aria-selected="true"] {
  color: #0d1117; background: var(--accent); border-color: var(--accent);
}

.status { display: flex; align-items: center; gap: 6px; min-width: 96px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4b5563;
  box-shadow: 0 0 0 0 #4b556366; transition: background .2s;
}
.dot.ok   { background: var(--up);   box-shadow: 0 0 8px #26a69a55; }
.dot.warn { background: #f59e0b;     box-shadow: 0 0 8px #f59e0b55; }
.dot.bad  { background: var(--down); box-shadow: 0 0 8px #ef535055; }
.status-text { color: var(--dim); font-size: 11px; }

.install {
  background: var(--accent); color: #0d1117; border: 0; border-radius: 5px;
  font: inherit; font-size: 11px; font-weight: 700; padding: 4px 8px; cursor: pointer;
}

/* ---------- chart ---------- */
.chartwrap { position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; touch-action: none; }

.empty {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; padding: 24px; gap: 6px;
  background: #0d1117cc; backdrop-filter: blur(2px); z-index: 20;
  pointer-events: none;   /* never block chart pan/zoom */
}
.empty strong { font-size: 14px; }
.empty p { color: var(--dim); margin: 0; max-width: 34ch; font-size: 12px; }

/* ---------- footer ---------- */
.foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 10px; border-top: 1px solid var(--line);
  background: var(--panel); color: var(--dim); font-size: 11px;
}

@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 7px 8px; }
  .last { font-size: 15px; }
  .status-text { display: none; }
  .status { min-width: 0; }
}
