#mob-drawtools-fab,
#mob-drawtools-sheet,
#mob-drawtools-scrim,
#mob-drawtools-gear { display: none; }

@media (max-width: 768px) {
  #mob-drawtools-fab,
  #mob-drawtools-sheet,
  #mob-drawtools-scrim { display: none; }

  body[data-mob-view="chart"] #mob-drawtools-fab {
    display: flex;
    position: fixed;
    left: 12px;
    bottom: calc(var(--m-tabbar-h, 58px) + env(safe-area-inset-bottom) + 14px);
    width: 46px; height: 46px;
    align-items: center; justify-content: center;
    border: 1px solid var(--border, #2a2d35);
    border-radius: 50%;
    background: var(--bg-secondary, #161a22);
    color: var(--text-primary, #d1d4dc);
    box-shadow: 0 3px 12px rgba(0,0,0,0.45);
    z-index: 190;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    transition: background .12s, transform .12s;
  }
  body[data-mob-view="chart"] #mob-drawtools-fab:active { transform: scale(0.92); }
  body[data-mob-view="chart"] #mob-drawtools-fab.is-armed {
    background: var(--accent, #2962ff);
    border-color: var(--accent, #2962ff);
    color: #fff;
  }
  #mob-drawtools-fab svg { width: 22px; height: 22px; pointer-events: none; }

  #mob-drawtools-gear { display: none; }
  body[data-mob-view="chart"] #mob-drawtools-gear.is-visible {
    display: flex;
    position: fixed;
    left: 12px;
    bottom: calc(var(--m-tabbar-h, 58px) + env(safe-area-inset-bottom) + 14px + 56px);
    width: 46px; height: 46px;
    align-items: center; justify-content: center;
    border: 1px solid var(--accent, #2962ff);
    border-radius: 50%;
    background: var(--bg-secondary, #161a22);
    color: var(--accent, #2962ff);
    box-shadow: 0 3px 12px rgba(0,0,0,0.45);
    z-index: 190;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    transition: background .12s, transform .12s;
  }
  body[data-mob-view="chart"] #mob-drawtools-gear.is-visible:active { transform: scale(0.92); }
  #mob-drawtools-gear svg { width: 22px; height: 22px; pointer-events: none; }
}

@media (min-width: 769px) and (pointer: coarse) {
  html[data-tablet-ui] body:not([data-mob-view]) #mob-drawtools-gear.is-visible {
    display: flex;
    position: fixed;
    left: 58px;
    bottom: 18px;
    width: 46px; height: 46px;
    align-items: center; justify-content: center;
    border: 1px solid var(--accent, #2962ff);
    border-radius: 50%;
    background: var(--bg-secondary, #161a22);
    color: var(--accent, #2962ff);
    box-shadow: 0 3px 12px rgba(0,0,0,0.45);
    z-index: 190;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    transition: background .12s, transform .12s;
  }
  html[data-tablet-ui] body:not([data-mob-view]) #mob-drawtools-gear.is-visible:active { transform: scale(0.92); }
  html[data-tablet-ui] #mob-drawtools-gear svg { width: 22px; height: 22px; pointer-events: none; }
}

#mob-drawtools-scrim.is-open {
  display: block;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 205;
}

#mob-drawtools-sheet.is-open { display: block; }
#mob-drawtools-sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--m-tabbar-h, 58px) + env(safe-area-inset-bottom, 0px));
  z-index: 206;
  background: var(--bg-secondary, #161a22);
  border-top: 1px solid var(--border, #2a2d35);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.5);
  padding: 0 0 14px;
  max-height: calc(100vh - var(--m-tabbar-h, 58px) - env(safe-area-inset-bottom, 0px) - 12px);
  max-height: calc(100dvh - var(--m-tabbar-h, 58px) - env(safe-area-inset-bottom, 0px) - 12px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform .22s ease;
}
#mob-drawtools-sheet.is-open { transform: translateY(0); }
#mob-drawtools-sheet.is-drag { transition: none; }
.mdt-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 0 8px;
  background: var(--bg-secondary, #161a22);
  border-radius: 14px 14px 0 0;
  touch-action: none;
  cursor: grab;
}
.mdt-grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border, #3a3d45);
  margin: 0 auto;
}
.mdt-row {
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 6px 10px;
  scrollbar-width: none;
}
.mdt-row::-webkit-scrollbar { display: none; }
.mdt-grouplabel {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted, #8b8f9a);
  padding: 6px 12px 0;
}
.mdt-tool {
  flex: 0 0 auto;
  width: 64px; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  background: var(--bg-tertiary, #1d2129);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 10px;
  color: var(--text-primary, #d1d4dc);
  font-family: inherit; font-size: 9px; line-height: 1.1; text-align: center;
  padding: 6px 4px;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.mdt-tool:active { background: var(--accent, #2962ff); color: #fff; }
.mdt-tool.is-active { border-color: var(--accent, #2962ff); color: var(--accent, #2962ff); }
.mdt-tool svg {
  width: 24px; height: 24px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.mdt-tool .mdt-lbl {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mdt-tool.mdt-danger { color: #ef5350; }
.mdt-tool.mdt-danger:active { background: #ef5350; color: #fff; }
