:root {
  --bg: #101214;
  --line: #23272d;
  --text: #e4e7eb;
  --dim: #8b919a;
  --chip: #2a2e35;
  --barh: 34px;
  --hit: 40px;   /* every control takes a finger: its touch area is at least this high and wide */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
}

body {
  position: fixed;
  inset: 0;
  font: 12px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after {
  box-sizing: border-box;
  touch-action: none;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
}

#app {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* the one slim line at the top; its controls' touch areas reach 6 px down into the chart's empty top */
#bar {
  position: absolute;
  top: var(--sat);
  left: var(--sal);
  right: var(--sar);
  height: var(--barh);
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 0 0 0 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 4;
}

#sym { font-weight: 600; font-size: 12.5px; line-height: var(--barh); flex: none; }
#live { width: 6px; height: 6px; margin-top: 14px; border-radius: 50%; background: #5b6169; flex: none; }
#live.on { background: #2fb383; }
#price { font-size: 13px; font-weight: 600; line-height: var(--barh); font-variant-numeric: tabular-nums; min-width: 60px; flex: none; }

#tfs { display: flex; align-items: flex-start; flex: 1 0 auto; height: var(--barh); }
#tfs button {
  flex: 1 1 0;
  min-width: var(--hit);
  max-width: 48px;
  height: var(--hit);
  padding: 0 0 calc(var(--hit) - var(--barh));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 12px;
}
#tfs button span { display: block; min-width: 27px; padding: 0 5px; line-height: 24px; border-radius: 6px; text-align: center; }
#tfs button.on { color: var(--text); font-weight: 600; }
#tfs button.on span { background: var(--chip); }
@media (max-width: 389px) {
  #tfs button { min-width: 36px; }
}

#ohlc { display: none; align-items: baseline; font-size: 11px; line-height: var(--barh); font-variant-numeric: tabular-nums; flex: 1 1 auto; min-width: 0; overflow: hidden; }
#ohlc i { font-style: normal; color: var(--dim); margin: 0 2px 0 5px; }
#ohlc i:first-child { margin-left: 0; }
#ohlc b { font-weight: 600; }
#bar.xh #price, #bar.xh #tfs { display: none; }
#bar.xh #ohlc { display: flex; }

#more {
  margin-left: auto;
  width: var(--hit);
  height: var(--hit);
  padding: 0 0 calc(var(--hit) - var(--barh));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex: none;
}
#more svg { display: block; }

/* the chart and what sits on it */
#stage {
  position: absolute;
  top: calc(var(--sat) + var(--barh));
  left: var(--sal);
  right: var(--sar);
  bottom: var(--sab);
}
#chart { position: absolute; inset: 0; }

/* the volume pane's own strip: an empty area over it, so a finger there changes nothing (the volume bars fit themselves) */
#vstrip { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 2; }
#vstrip[hidden] { display: none; }

/* the frames counter: small, in the chart's empty top-left corner, never under a finger */
#fps {
  position: absolute;
  left: 6px;
  top: 8px;
  color: var(--dim);
  font-size: 10px;
  line-height: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

/* while the live line is down: a short note on the chart's empty top, over the candles' width */
#note {
  position: absolute;
  left: 0;
  right: 66px;
  top: 7px;
  margin: 0;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
#note[hidden] { display: none; }
#note span {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  border: 1px solid #3d424a;
  background: rgba(16, 18, 20, 0.9);
  color: var(--text);
  font-size: 11px;
  line-height: 13px;
  white-space: nowrap;
}

/* "A": the auto fit switch in the corner cell at the foot of the price strip; its touch area reaches up from the cell */
#auto {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 66px;
  height: var(--hit);
  z-index: 2;
}
#auto span {
  position: absolute;
  left: 50%;
  top: 16px;
  width: 24px;
  height: 19px;
  margin-left: -12px;
  border-radius: 4px;
  border: 1px solid #3d424a;
  background: rgba(16, 18, 20, 0.9);
  color: var(--dim);
  font: 600 10.5px/17px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  text-align: center;
}
#auto.on span { color: #101214; background: #c9ced6; border-color: #c9ced6; }

/* "back to the newest": a small pill at the last price's height inside a finger-sized touch area */
#back {
  position: absolute;
  right: 64px;
  top: 0;
  width: var(--hit);
  height: var(--hit);
  z-index: 2;
}
#back[hidden] { display: none; }
#back span {
  position: absolute;
  left: 5px;
  top: 9px;
  width: 30px;
  height: 22px;
  border-radius: 11px;
  border: 1px solid #4a505a;
  background: rgba(30, 33, 38, 0.94);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
#back svg { display: block; }

#msg {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 38%;
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  z-index: 3;
}

/* the sheet behind "..." */
#sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 10; }
#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  padding: 0 calc(18px + var(--sar)) calc(12px + var(--sab)) calc(18px + var(--sal));
  background: #1b1e23;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
}
#sheet[hidden], #sheet-back[hidden] { display: none; }
#sheet .head { position: relative; height: 44px; }
.grip { position: absolute; left: 50%; top: 8px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: #3d424a; }
#sheet-close {
  position: absolute;
  right: -14px;
  top: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
}
#sheet-close svg { display: block; }
.row { display: flex; align-items: center; justify-content: space-between; min-height: 50px; font-size: 15px; gap: 12px; }
.credit { margin: 8px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--dim); white-space: normal; }
.credit a { color: var(--text); text-decoration: underline; padding: 4px 0; }

input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 48px;
  height: 29px;
  margin: 0;
  border-radius: 15px;
  background: #3d424a;
  position: relative;
  transition: background 0.15s;
}
input[role="switch"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
input[role="switch"]:checked { background: #2fb383; }
input[role="switch"]:checked::after { transform: translateX(19px); }
