:root {
  --bg: #0a0a0a;
  --bg-panel: #111120;
  --bg-hdr: #0a120a;
  --green: #00ff88;
  --green-dim: #00aa55;
  --white: #e0e0e0;
  --yellow: #ffcc00;
  --red: #ff4444;
  --gray: #555566;
  --dim: #1e1e30;
  --border: #1a3a2a;
  --mono: Consolas, "SF Mono", "Courier New", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--white);
  font-family: var(--mono);
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

body {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
}
#topbar  { flex: 0 0 auto; }
#jarvisRead { flex: 0 0 auto; }

button {
  font-family: var(--mono);
  cursor: pointer;
}

/* ── login overlay ─────────────────────────────────────────────────────── */
#loginOverlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  touch-action: auto;
}
#loginOverlay.hidden { display: none !important; }
#loginBox {
  width: min(320px, 90vw);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
#loginTitle {
  font-size: 16px; font-weight: bold; color: var(--green);
  letter-spacing: 2px; text-align: center; margin-bottom: 10px;
}
#loginBox label { font-size: 10px; color: var(--gray); margin-top: 6px; }
#loginBox input {
  background: #0d0d1a; color: var(--white);
  border: 1px solid var(--dim); border-radius: 3px;
  font-family: var(--mono); font-size: 13px;
  padding: 8px;
}
#loginBtn {
  margin-top: 14px;
  background: #1a3a1a; color: var(--green);
  border: 1px solid var(--green); border-radius: 3px;
  font-size: 12px; font-weight: bold; letter-spacing: 1px;
  padding: 10px;
}
#loginError { font-size: 11px; color: var(--red); min-height: 14px; }

#topbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}

#pairRow { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }

#pairInput {
  flex: 1;
  background: #0d0d1a; color: var(--green);
  border: 1px solid var(--dim); border-radius: 3px;
  font-family: var(--mono); font-size: 13px; font-weight: bold;
  padding: 6px 8px;
}

#refreshBtn {
  background: var(--dim); color: var(--white);
  border: none; border-radius: 3px;
  font-size: 14px; padding: 6px 10px;
}

#statusTxt { font-size: 10px; color: var(--gray); white-space: nowrap; }

#tfRow { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }

#tfBtns { display: flex; gap: 4px; flex: 1; overflow-x: auto; }

.tfBtn {
  background: var(--dim); color: var(--gray);
  border: 1px solid transparent; border-radius: 3px;
  font-size: 11px; padding: 6px 10px; flex-shrink: 0;
}
.tfBtn.active { color: var(--green); border-color: var(--green); background: #1a3a1a; }

.ghostBtn {
  background: var(--dim); color: var(--gray);
  border: 1px solid var(--dim); border-radius: 3px;
  font-size: 10px; padding: 6px 8px; white-space: nowrap;
}
.ghostBtn.on { color: var(--green); border-color: var(--green); }

#actionRow { display: flex; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }

.analyzeBtn {
  background: #2a2400; color: var(--yellow);
  border: 1px solid var(--yellow); border-radius: 3px;
  font-size: 11px; font-weight: bold; padding: 6px 10px;
}
.analyzeBtn:disabled { opacity: 0.5; }

#usageRow { font-size: 9px; color: var(--gray); }

#chartWrap {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#mainCanvas { width: 100%; display: block; touch-action: none; }
#volCanvas  { width: 100%; display: block; height: 48px; border-top: 1px solid var(--dim); }
#rsiCanvas  { width: 100%; display: block; height: 70px; border-top: 1px solid var(--dim); }

#ohlcTooltip {
  position: absolute;
  background: #141428; border: 1px solid var(--green-dim);
  border-radius: 3px; padding: 6px 8px;
  font-size: 10px; color: var(--white);
  pointer-events: none; line-height: 1.5;
  z-index: 50;
}
#ohlcTooltip .lbl { color: var(--gray); margin-right: 4px; }

#loadingMsg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: var(--green); font-size: 13px; font-weight: bold;
}

.hidden { display: none !important; }

/* ── drawing tool palette ──────────────────────────────────────────────── */
#drawToolbar {
  flex: 0 0 auto;
  display: flex; gap: 4px; flex-wrap: wrap;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 6px 8px;
}
.drawTool {
  background: var(--dim); color: var(--gray);
  border: 1px solid var(--dim); border-radius: 3px;
  font-size: 10px; padding: 6px 8px;
}
.drawTool.active { color: var(--yellow); border-color: var(--yellow); background: #2a2400; }
#drawDoneBtn {
  margin-left: auto;
  background: var(--dim); color: var(--red);
  border: 1px solid var(--red); border-radius: 3px;
  font-size: 10px; padding: 6px 8px;
}

#jarvisRead {
  background: var(--bg-panel);
  border-top: 1px solid var(--dim);
  padding: 4px 8px 10px;
}
#jarvisReadLabel {
  font-size: 9px; color: var(--green-dim); letter-spacing: 1px;
  margin-bottom: 2px;
}
#jarvisReadText {
  font-size: 11px; color: var(--green);
  max-height: 4.5em; overflow-y: auto; white-space: pre-wrap;
}

.drawer {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-height: 70vh;
  background: #14142a;
  border-top: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  z-index: 101;
  display: flex; flex-direction: column;
  touch-action: auto;
}
.drawerHead {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--dim);
  font-size: 12px; color: var(--green-dim); letter-spacing: 1px;
}
.closeBtn {
  background: none; border: none; color: var(--gray);
  font-size: 20px; line-height: 1; padding: 0 4px;
}
.drawerBody {
  overflow-y: auto;
  padding: 4px 0 24px;
  touch-action: auto;
}

#drawerScrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}

.sectionHead {
  font-size: 9px; color: var(--gray); letter-spacing: 1px;
  padding: 10px 14px 4px;
}

.toggleRow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #1a1a30;
}
.toggleRow .name { flex: 1; font-size: 12px; color: var(--white); }
.toggleRow input[type=checkbox] {
  width: 20px; height: 20px; accent-color: var(--green);
}
.toggleRow .swatch {
  width: 16px; height: 16px; border-radius: 3px; border: 1px solid #333;
}
